37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace KTXF\Mail\Object;
|
|
|
|
/**
|
|
* Shared Message Part implementation matching the frontend JSON shape.
|
|
*/
|
|
class MessagePart extends MessagePartMutableAbstract {
|
|
|
|
public static function fromArray(array $data): self {
|
|
$part = new self();
|
|
$part->data = $data;
|
|
|
|
if (isset($part->data[MessagePartInterface::PROPERTY_SUB_PARTS]) && is_array($part->data[MessagePartInterface::PROPERTY_SUB_PARTS])) {
|
|
foreach ($part->data[MessagePartInterface::PROPERTY_SUB_PARTS] as $entry) {
|
|
if (is_object($entry)) {
|
|
$entry = get_object_vars($entry);
|
|
}
|
|
|
|
if (is_array($entry)) {
|
|
$part->parts[] = self::fromArray($entry);
|
|
}
|
|
}
|
|
|
|
unset($part->data[MessagePartInterface::PROPERTY_SUB_PARTS]);
|
|
}
|
|
|
|
return $part;
|
|
}
|
|
} |