* SPDX-License-Identifier: AGPL-3.0-or-later */ namespace KTXF\Mail\Collection; use KTXF\Resource\Provider\Node\NodePropertiesBaseAbstract; /** * Abstract Mail Collection Properties Base Class * * Provides common implementation for mail collection properties * * @since 2025.05.01 */ abstract class CollectionPropertiesBaseAbstract extends NodePropertiesBaseAbstract implements CollectionPropertiesBaseInterface { /** * @inheritDoc */ public function total(): int { return $this->data[static::PROPERTY_TOTAL] ?? 0; } /** * @inheritDoc */ public function unread(): int { return $this->data[static::PROPERTY_UNREAD] ?? 0; } /** * @inheritDoc */ public function getLabel(): string { return $this->data[static::PROPERTY_LABEL] ?? ''; } /** * @inheritDoc */ public function getRole(): CollectionRoles { return isset($this->data[static::PROPERTY_ROLE]) ? ($this->data[static::PROPERTY_ROLE] instanceof CollectionRoles ? $this->data[static::PROPERTY_ROLE] : CollectionRoles::from($this->data[static::PROPERTY_ROLE])) : CollectionRoles::None; } /** * @inheritDoc */ public function getRank(): int { return $this->data[static::PROPERTY_RANK] ?? 0; } /** * @inheritDoc */ public function getSubscription(): bool { return $this->data[static::PROPERTY_SUBSCRIPTION] ?? false; } }