generated from Nodarx/template
refactor: use custom imap client
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
54
lib/Client/Command/Result/StatusResult.php
Normal file
54
lib/Client/Command/Result/StatusResult.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user