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