refactor: use custom imap client

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-05-08 00:16:43 -04:00
parent a728aeb11c
commit a8764747fd
179 changed files with 6782 additions and 5907 deletions

View File

@@ -2,32 +2,101 @@
declare(strict_types=1);
namespace Gricob\IMAP;
namespace KTXM\ProviderImap\Client;
class Mailbox
use KTXM\ProviderImap\Client\Command\Result\StatusResult;
final class Mailbox
{
private const ATTRIBUTE_NOSELECT = '\Noselect';
public array $flags = [];
public int $exists = 0;
public int $recent = 0;
public ?int $unseen = null;
public ?int $uidValidity = null;
public ?int $uidNext = null;
public array $permanentFlags = [];
/**
* @param list<string> $nameAttributes
* @param list<string> $attributes
* @param list<string> $flags
*/
public function __construct(
public array $nameAttributes,
public string $hierarchyDelimiter,
public string $name,
) {
private readonly string $name,
private readonly ?string $delimiter,
private readonly array $attributes,
private readonly int $messages = 0,
private readonly int $unread = 0,
private readonly ?int $state = null,
private readonly int $recent = 0,
private readonly array $flags = [],
private readonly bool $readOnly = true,
) {}
public function fromStatus(StatusResult $status): self
{
return new self(
$this->name,
$this->delimiter,
$this->attributes,
$status->messages() ?? $this->messages,
$status->unseen() ?? $this->unread,
$status->state() ?? $this->state,
$this->recent,
$this->flags,
$this->readOnly,
);
}
public function name(): string
{
return $this->name;
}
public function delimiter(): ?string
{
return $this->delimiter;
}
/**
* @return list<string>
*/
public function attributes(): array
{
return $this->attributes;
}
public function state(): ?int
{
return $this->state;
}
public function messages(): int
{
return $this->messages;
}
public function unread(): int
{
return $this->unread;
}
public function read(): int
{
return max(0, $this->messages - $this->unread);
}
public function recent(): int
{
return $this->recent;
}
/**
* @return list<string>
*/
public function flags(): array
{
return $this->flags;
}
public function readOnly(): bool
{
return $this->readOnly;
}
public function isSelectable(): bool
{
return !in_array(self::ATTRIBUTE_NOSELECT, $this->nameAttributes);
return !in_array('\\NOSELECT', $this->attributes, true);
}
}