Files
provider_jmapc/lib/Providers/Document/EntityProperties.php
T
Sebastian dbfb5f8b37 feat: implement node list
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-10-01 21:10:42 -04:00

55 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderJmapc\Providers\Document;
use KTXF\Documents\Entity\EntityPropertiesMutableAbstract;
/**
* Document Collection Properties Implementation
*/
class EntityProperties extends EntityPropertiesMutableAbstract {
/**
* Convert JMAP parameters array to document entity properties object
*
* @param array $parameters JMAP parameters array
*/
public function fromJmap(array $parameters): static {
if (isset($parameters['size'])) {
$this->data[self::PROPERTY_SIZE] = (int) $parameters['size'];
}
if (isset($parameters['name'])) {
$this->data[self::PROPERTY_LABEL] = (string) $parameters['name'];
}
if (isset($parameters['type'])) {
$this->data[self::PROPERTY_MIME] = (string) $parameters['type'];
}
return $this;
}
/**
* Convert document entity properties object to JMAP parameters array
*/
public function toJmap(): array {
$parameters = array_filter([
'name' => $this->data[self::PROPERTY_LABEL],
'type' => $this->data[self::PROPERTY_MIME] ?? 'application/octet-stream'
], static fn($value) => $value !== null);
return $parameters;
}
}