66 lines
1.4 KiB
PHP
66 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace MailAccountAdmin\Models;
|
||
|
|
|
||
|
|
use DateTimeImmutable;
|
||
|
|
|
||
|
|
class Alias
|
||
|
|
{
|
||
|
|
/** @var int */
|
||
|
|
private $id;
|
||
|
|
/** @var int */
|
||
|
|
private $userId;
|
||
|
|
/** @var string */
|
||
|
|
private $mailAddress;
|
||
|
|
/** @var DateTimeImmutable */
|
||
|
|
private $createdAt;
|
||
|
|
/** @var DateTimeImmutable */
|
||
|
|
private $modifiedAt;
|
||
|
|
|
||
|
|
private function __construct(int $id, int $userId, string $mailAddress, DateTimeImmutable $createdAt, DateTimeImmutable $modifiedAt)
|
||
|
|
{
|
||
|
|
$this->id = $id;
|
||
|
|
$this->userId = $userId;
|
||
|
|
$this->mailAddress = $mailAddress;
|
||
|
|
$this->createdAt = $createdAt;
|
||
|
|
$this->modifiedAt = $modifiedAt;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function createFromArray(array $data): self
|
||
|
|
{
|
||
|
|
return new self(
|
||
|
|
(int)$data['alias_id'],
|
||
|
|
(int)$data['user_id'],
|
||
|
|
$data['mail_address'],
|
||
|
|
new DateTimeImmutable($data['created_at']),
|
||
|
|
new DateTimeImmutable($data['modified_at']),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getId(): int
|
||
|
|
{
|
||
|
|
return $this->id;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getUserId(): int
|
||
|
|
{
|
||
|
|
return $this->userId;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getMailAddress(): string
|
||
|
|
{
|
||
|
|
return $this->mailAddress;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getCreatedAt(): DateTimeImmutable
|
||
|
|
{
|
||
|
|
return $this->createdAt;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getModifiedAt(): DateTimeImmutable
|
||
|
|
{
|
||
|
|
return $this->modifiedAt;
|
||
|
|
}
|
||
|
|
}
|