generated from Nodarx/template
54 lines
1018 B
PHP
54 lines
1018 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXM\ProviderImap\Client\Command\Result;
|
|
|
|
final class StatusResult
|
|
{
|
|
/**
|
|
* @param array<string, int> $items
|
|
*/
|
|
public function __construct(
|
|
private readonly string $mailbox,
|
|
private readonly array $items,
|
|
) {}
|
|
|
|
public function mailbox(): string
|
|
{
|
|
return $this->mailbox;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, int>
|
|
*/
|
|
public function items(): array
|
|
{
|
|
return $this->items;
|
|
}
|
|
|
|
public function value(string $item, int $default = 0): int
|
|
{
|
|
return $this->items[strtoupper(trim($item))] ?? $default;
|
|
}
|
|
|
|
public function messages(): int
|
|
{
|
|
return $this->value('MESSAGES');
|
|
}
|
|
|
|
public function unseen(): int
|
|
{
|
|
return $this->value('UNSEEN');
|
|
}
|
|
|
|
public function read(): int
|
|
{
|
|
return max(0, $this->messages() - $this->unseen());
|
|
}
|
|
|
|
public function state(): int
|
|
{
|
|
return $this->value('UIDVALIDITY');
|
|
}
|
|
} |