generated from Nodarx/template
50 lines
962 B
PHP
50 lines
962 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXM\ProviderImap\Client;
|
|
|
|
final class MessageAddress
|
|
{
|
|
public function __construct(
|
|
private readonly ?string $name,
|
|
private readonly ?string $mailbox,
|
|
private readonly ?string $host,
|
|
) {}
|
|
|
|
public function name(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function mailbox(): ?string
|
|
{
|
|
return $this->mailbox;
|
|
}
|
|
|
|
public function host(): ?string
|
|
{
|
|
return $this->host;
|
|
}
|
|
|
|
public function email(): ?string
|
|
{
|
|
if ($this->mailbox === null || $this->mailbox === '') {
|
|
return null;
|
|
}
|
|
|
|
if ($this->host === null || $this->host === '') {
|
|
return $this->mailbox;
|
|
}
|
|
|
|
return $this->mailbox . '@' . $this->host;
|
|
}
|
|
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'address' => $this->email(),
|
|
'label' => $this->name,
|
|
];
|
|
}
|
|
} |