generated from Nodarx/template
refactor: mailbox status names
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace KTXM\ProviderImap\Client;
|
namespace KTXM\ProviderImap\Client;
|
||||||
|
|
||||||
use KTXM\ProviderImap\Client\Result\StatusResult;
|
use KTXM\ProviderImap\Client\Result\MailboxStatusResult;
|
||||||
|
|
||||||
final class Mailbox
|
final class Mailbox
|
||||||
{
|
{
|
||||||
@@ -18,13 +18,13 @@ final class Mailbox
|
|||||||
private readonly array $attributes,
|
private readonly array $attributes,
|
||||||
private readonly int $messages = 0,
|
private readonly int $messages = 0,
|
||||||
private readonly int $unread = 0,
|
private readonly int $unread = 0,
|
||||||
private readonly ?int $state = null,
|
private readonly ?int $uidValidity = null,
|
||||||
private readonly int $recent = 0,
|
private readonly int $recent = 0,
|
||||||
private readonly array $flags = [],
|
private readonly array $flags = [],
|
||||||
private readonly bool $readOnly = true,
|
private readonly bool $readOnly = true,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function fromStatus(StatusResult $status): self
|
public function fromStatus(MailboxStatusResult $status): self
|
||||||
{
|
{
|
||||||
return new self(
|
return new self(
|
||||||
$this->name,
|
$this->name,
|
||||||
@@ -32,7 +32,7 @@ final class Mailbox
|
|||||||
$this->attributes,
|
$this->attributes,
|
||||||
$status->messages() ?? $this->messages,
|
$status->messages() ?? $this->messages,
|
||||||
$status->unseen() ?? $this->unread,
|
$status->unseen() ?? $this->unread,
|
||||||
$status->state() ?? $this->state,
|
$status->uidValidity() ?? $this->uidValidity,
|
||||||
$this->recent,
|
$this->recent,
|
||||||
$this->flags,
|
$this->flags,
|
||||||
$this->readOnly,
|
$this->readOnly,
|
||||||
@@ -57,9 +57,9 @@ final class Mailbox
|
|||||||
return $this->attributes;
|
return $this->attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function state(): ?int
|
public function uidValidity(): ?int
|
||||||
{
|
{
|
||||||
return $this->state;
|
return $this->uidValidity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function messages(): int
|
public function messages(): int
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ final class ListCommand implements CommandInterface
|
|||||||
$mailbox->attributes(),
|
$mailbox->attributes(),
|
||||||
$status['MESSAGES'] ?? $mailbox->messages(),
|
$status['MESSAGES'] ?? $mailbox->messages(),
|
||||||
$status['UNSEEN'] ?? $mailbox->unread(),
|
$status['UNSEEN'] ?? $mailbox->unread(),
|
||||||
$mailbox->state(),
|
$mailbox->uidValidity(),
|
||||||
$mailbox->recent(),
|
$mailbox->recent(),
|
||||||
$mailbox->flags(),
|
$mailbox->flags(),
|
||||||
$mailbox->readOnly(),
|
$mailbox->readOnly(),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace KTXM\ProviderImap\Client\Protocol\Command;
|
|||||||
|
|
||||||
use KTXM\ProviderImap\Client\Protocol\StringEncoder;
|
use KTXM\ProviderImap\Client\Protocol\StringEncoder;
|
||||||
use KTXM\ProviderImap\Client\Protocol\Parser\StatusResponseParser;
|
use KTXM\ProviderImap\Client\Protocol\Parser\StatusResponseParser;
|
||||||
use KTXM\ProviderImap\Client\Result\StatusResult;
|
use KTXM\ProviderImap\Client\Result\MailboxStatusResult;
|
||||||
use KTXM\ProviderImap\Client\ImapException;
|
use KTXM\ProviderImap\Client\ImapException;
|
||||||
use KTXM\ProviderImap\Client\Protocol\RequestFrame;
|
use KTXM\ProviderImap\Client\Protocol\RequestFrame;
|
||||||
use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse;
|
use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse;
|
||||||
@@ -16,7 +16,7 @@ use KTXM\ProviderImap\Client\Protocol\SessionContext;
|
|||||||
use KTXM\ProviderImap\Client\Protocol\SessionState;
|
use KTXM\ProviderImap\Client\Protocol\SessionState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @implements CommandInterface<StatusResult>
|
* @implements CommandInterface<MailboxStatusResult>
|
||||||
*/
|
*/
|
||||||
final class StatusCommand implements CommandInterface
|
final class StatusCommand implements CommandInterface
|
||||||
{
|
{
|
||||||
@@ -57,7 +57,7 @@ final class StatusCommand implements CommandInterface
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(ResponseStream $responses, SessionContext $context): StatusResult
|
public function handle(ResponseStream $responses, SessionContext $context): MailboxStatusResult
|
||||||
{
|
{
|
||||||
unset($context);
|
unset($context);
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ final class StatusCommand implements CommandInterface
|
|||||||
throw new ImapException('STATUS failed: ' . $response->text());
|
throw new ImapException('STATUS failed: ' . $response->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StatusResult($mailbox, $items);
|
return new MailboxStatusResult($mailbox, $items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace KTXM\ProviderImap\Client\Result;
|
namespace KTXM\ProviderImap\Client\Result;
|
||||||
|
|
||||||
final class StatusResult
|
final class MailboxStatusResult
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array<string, int> $items
|
* @param array<string, int> $items
|
||||||
@@ -47,7 +47,7 @@ final class StatusResult
|
|||||||
return max(0, $this->messages() - $this->unseen());
|
return max(0, $this->messages() - $this->unseen());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function state(): int
|
public function uidValidity(): int
|
||||||
{
|
{
|
||||||
return $this->value('UIDVALIDITY');
|
return $this->value('UIDVALIDITY');
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user