61 lines
1.3 KiB
PHP
61 lines
1.3 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace MailAccountAdmin\Models;
|
|
|
|
use DateTimeImmutable;
|
|
|
|
class Alias
|
|
{
|
|
private int $id;
|
|
private int $userId;
|
|
private string $mailAddress;
|
|
private DateTimeImmutable $createdAt;
|
|
private DateTimeImmutable $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;
|
|
}
|
|
}
|