Files
server/shared/lib/Chrono/Collection/CollectionPropertiesBaseAbstract.php
Sebastian Krupinski 18f8f0e1d1
All checks were successful
JS Unit Tests / test (pull_request) Successful in 13s
Build Test / build (pull_request) Successful in 17s
PHP Unit Tests / test (pull_request) Successful in 48s
chore: standardize chrono provider
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-02-17 03:09:38 -05:00

77 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Chrono\Collection;
use KTXF\Resource\Provider\Node\NodePropertiesBaseAbstract;
/**
* Abstract Chrono Collection Properties Base Class
*
* Provides common implementation for chrono collection properties
*
* @since 2025.05.01
*/
abstract class CollectionPropertiesBaseAbstract extends NodePropertiesBaseAbstract implements CollectionPropertiesBaseInterface {
public const JSON_TYPE = CollectionPropertiesBaseInterface::JSON_TYPE;
/**
* @inheritDoc
*/
public function content(): CollectionContent {
$content = $this->data[self::JSON_PROPERTY_CONTENTS] ?? null;
if ($content instanceof CollectionContent) {
return $content;
}
if (is_string($content)) {
return CollectionContent::tryFrom($content) ?? CollectionContent::Event;
}
return CollectionContent::Event;
}
/**
* @inheritDoc
*/
public function getLabel(): string {
return $this->data[self::JSON_PROPERTY_LABEL] ?? '';
}
/**
* @inheritDoc
*/
public function getDescription(): ?string {
return $this->data[self::JSON_PROPERTY_DESCRIPTION] ?? null;
}
/**
* @inheritDoc
*/
public function getPriority(): ?int {
return $this->data[self::JSON_PROPERTY_PRIORITY] ?? null;
}
/**
* @inheritDoc
*/
public function getVisibility(): ?bool {
return $this->data[self::JSON_PROPERTY_VISIBILITY] ?? null;
}
/**
* @inheritDoc
*/
public function getColor(): ?string {
return $this->data[self::JSON_PROPERTY_COLOR] ?? null;
}
}