69 lines
1.6 KiB
PHP
69 lines
1.6 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace MailAccountAdmin\Models;
|
|
|
|
use DateTimeImmutable;
|
|
|
|
class AdminUser
|
|
{
|
|
private int $id;
|
|
private string $username;
|
|
private string $passwordHash;
|
|
private bool $active;
|
|
private DateTimeImmutable $createdAt;
|
|
private DateTimeImmutable $modifiedAt;
|
|
|
|
private function __construct(int $id, string $username, string $passwordHash, bool $isActive,
|
|
DateTimeImmutable $createdAt, DateTimeImmutable $modifiedAt)
|
|
{
|
|
$this->id = $id;
|
|
$this->username = $username;
|
|
$this->passwordHash = $passwordHash;
|
|
$this->active = $isActive;
|
|
$this->createdAt = $createdAt;
|
|
$this->modifiedAt = $modifiedAt;
|
|
}
|
|
|
|
public static function createFromArray(array $data): self
|
|
{
|
|
return new self(
|
|
(int)$data['admin_id'],
|
|
$data['username'],
|
|
$data['password'],
|
|
$data['is_active'] === '1',
|
|
new DateTimeImmutable($data['created_at']),
|
|
new DateTimeImmutable($data['modified_at']),
|
|
);
|
|
}
|
|
|
|
public function getId(): int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getUsername(): string
|
|
{
|
|
return $this->username;
|
|
}
|
|
|
|
public function getPasswordHash(): string
|
|
{
|
|
return $this->passwordHash;
|
|
}
|
|
|
|
public function isActive(): bool
|
|
{
|
|
return $this->active;
|
|
}
|
|
|
|
public function getCreatedAt(): DateTimeImmutable
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function getModifiedAt(): DateTimeImmutable
|
|
{
|
|
return $this->modifiedAt;
|
|
}
|
|
}
|