refactor: standardize design
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
40
lib/Providers/Personal/CollectionProperties.php
Normal file
40
lib/Providers/Personal/CollectionProperties.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user