Files
server/shared/lib/Mail/Collection/CollectionPropertiesBaseAbstract.php
Sebastian Krupinski f3c882454d
All checks were successful
Build Test / build (pull_request) Successful in 12s
JS Unit Tests / test (pull_request) Successful in 11s
PHP Unit Tests / test (pull_request) Successful in 39s
refactor: mail interfaces
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-05-14 22:54:51 -04:00

67 lines
1.6 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\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;
}
}