cc1deb4c07
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
55 lines
1.3 KiB
PHP
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] ?? null,
|
|
'type' => $this->data[self::PROPERTY_MIME] ?? null
|
|
], static fn($value) => $value !== null);
|
|
|
|
return $parameters;
|
|
}
|
|
|
|
}
|