chore: standardize chrono provider

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-02-17 03:11:54 -05:00
parent f3d2e2690b
commit 5c6d508cac
7 changed files with 451 additions and 529 deletions

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderLocalChrono\Providers\Personal;
use KTXF\Chrono\Entity\EntityPropertiesMutableAbstract;
class EntityProperties extends EntityPropertiesMutableAbstract {
public function jsonSerialize(): array {
$data = $this->getDataRaw();
if (is_array($data)) {
return $data;
}
return [];
}
public function jsonDeserialize(array|string $data): static {
if (is_string($data)) {
$data = json_decode($data, true);
}
if (is_array($data) && array_key_exists('data', $data)) {
$this->setDataRaw($data['data']);
return $this;
}
$this->setDataRaw($data);
return $this;
}
public function fromStore(array $data): static {
$this->setDataRaw($data['data'] ?? null);
return $this;
}
public function toStore(): array {
return array_filter([
'data' => $this->getDataRaw(),
], static fn($value) => $value !== null);
}
}