Files
server/shared/lib/Documents/Collection/CollectionPropertiesBaseAbstract.php
2026-07-09 19:31:09 -04:00

43 lines
1.1 KiB
PHP

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