* SPDX-License-Identifier: AGPL-3.0-or-later */ namespace KTXF\Mail\Object; /** * Abstract Message Part Base Class * * Provides common implementation for message parts (read-only) * * @since 2025.05.01 */ abstract class MessagePartBaseAbstract implements MessagePartInterface { /** * Internal data storage */ protected array $data = []; /** * Sub-parts storage * @var array */ protected array $parts = []; /** * Constructor * * @param array &$data Reference to data array */ public function __construct(array &$data = null) { if ($data === null) { $data = []; } $this->data = &$data; } /** * @inheritDoc */ public function getBlobId(): ?string { return $this->data['blobId'] ?? null; } /** * @inheritDoc */ public function getId(): ?string { return $this->data['partId'] ?? null; } /** * @inheritDoc */ public function getType(): ?string { return $this->data['type'] ?? null; } /** * @inheritDoc */ public function getDisposition(): ?string { return $this->data['disposition'] ?? null; } /** * @inheritDoc */ public function getName(): ?string { return $this->data['name'] ?? null; } /** * @inheritDoc */ public function getCharset(): ?string { return $this->data['charset'] ?? null; } /** * @inheritDoc */ public function getLanguage(): ?string { return $this->data['language'] ?? null; } /** * @inheritDoc */ public function getLocation(): ?string { return $this->data['location'] ?? null; } /** * @inheritDoc */ public function getParts(): array { return $this->parts; } /** * @inheritDoc */ public function jsonSerialize(): array { $result = $this->data; if (!empty($this->parts)) { $result['subParts'] = []; foreach ($this->parts as $part) { $result['subParts'][] = $part->jsonSerialize(); } } return $result; } }