Files
provider_imap/lib/Client/Message.php
2026-05-14 22:50:21 -04:00

185 lines
3.8 KiB
PHP

<?php
declare(strict_types=1);
namespace KTXM\ProviderImap\Client;
final class Message
{
/**
* @param list<string> $flags
* @param list<MessageAddress> $from
* @param list<MessageAddress> $sender
* @param list<MessageAddress> $replyTo
* @param list<MessageAddress> $to
* @param list<MessageAddress> $cc
* @param list<MessageAddress> $bcc
* @param array<string, string> $bodySections
*/
public function __construct(
private readonly int $sequence,
private readonly int $uid,
private readonly int $size,
private readonly ?string $internalDate,
private readonly ?string $receivedAt,
private readonly array $flags,
private readonly ?string $subject,
private readonly ?string $sentAt,
private readonly ?string $messageId,
private readonly ?string $inReplyTo,
private readonly array $from,
private readonly array $sender,
private readonly array $replyTo,
private readonly array $to,
private readonly array $cc,
private readonly array $bcc,
private readonly ?MessagePart $bodyStructure,
private readonly array $bodySections,
) {}
public function sequence(): int
{
return $this->sequence;
}
public function uid(): int
{
return $this->uid;
}
public function size(): int
{
return $this->size;
}
public function internalDate(): ?string
{
return $this->internalDate;
}
public function receivedAt(): ?string
{
return $this->receivedAt;
}
/**
* @return list<string>
*/
public function flags(): array
{
return $this->flags;
}
public function subject(): ?string
{
return $this->subject;
}
public function sentAt(): ?string
{
return $this->sentAt;
}
public function messageId(): ?string
{
return $this->messageId;
}
public function inReplyTo(): ?string
{
return $this->inReplyTo;
}
/**
* @return list<MessageAddress>
*/
public function from(): array
{
return $this->from;
}
/**
* @return list<MessageAddress>
*/
public function sender(): array
{
return $this->sender;
}
/**
* @return list<MessageAddress>
*/
public function replyTo(): array
{
return $this->replyTo;
}
/**
* @return list<MessageAddress>
*/
public function to(): array
{
return $this->to;
}
/**
* @return list<MessageAddress>
*/
public function cc(): array
{
return $this->cc;
}
/**
* @return list<MessageAddress>
*/
public function bcc(): array
{
return $this->bcc;
}
public function bodyStructure(): ?MessagePart
{
return $this->bodyStructure;
}
public function bodyText(): ?string
{
return $this->bodySections['TEXT'] ?? null;
}
/**
* @return array<string, string>
*/
public function bodySections(): array
{
return $this->bodySections;
}
/**
* @param array<string, string> $bodySections
*/
public function withBodyData(?MessagePart $bodyStructure, array $bodySections): self
{
return new self(
$this->sequence,
$this->uid,
$this->size,
$this->internalDate,
$this->receivedAt,
$this->flags,
$this->subject,
$this->sentAt,
$this->messageId,
$this->inReplyTo,
$this->from,
$this->sender,
$this->replyTo,
$this->to,
$this->cc,
$this->bcc,
$bodyStructure,
$bodySections,
);
}
}