Files
provider_local_documents/lib/Providers/Personal/CollectionProperties.php
2026-03-03 22:10:46 -05:00

41 lines
901 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderLocalDocuments\Providers\Personal;
use KTXF\Resource\Documents\Collection\CollectionPropertiesMutableAbstract;
class CollectionProperties extends CollectionPropertiesMutableAbstract {
/**
* Converts store document values into collection properties.
*/
public function fromStore(array|object $data): static {
if (is_object($data)) {
$data = (array) $data;
}
if (isset($data['label'])) {
$this->data[self::JSON_PROPERTY_LABEL] = (string) $data['label'];
}
return $this;
}
/**
* Converts collection properties into store document values.
*/
public function toStore(): array {
return array_filter([
'label' => $this->getLabel(),
], static fn($value) => $value !== null);
}
}