<?php
declare(strict_types=1);
namespace App\Domain\Administrator\Model;
use App\Domain\Shared\Model\Aggregate;
use App\Domain\Shared\Model\TimestampTrait;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Uid\Uuid;
class Administrator extends Aggregate implements UserInterface, PasswordAuthenticatedUserInterface
{
use TimestampTrait;
public function __construct(
private Uuid $id,
private string $email,
private string $password,
private AdministratorRole $role,
private bool $active
) {
$this->createdAt = new \DateTimeImmutable();
$this->updatedAt = null;
}
public function getId(): Uuid
{
return $this->id;
}
public function getRoles(): array
{
return [$this->role->value];
}
public function getRole(): AdministratorRole
{
return $this->role;
}
public function eraseCredentials(): void
{
// TODO: Implement eraseCredentials() method.
}
public function getUserIdentifier(): string
{
return $this->email;
}
public function setPassword(string $password): void
{
$this->password = $password;
}
public function getPassword(): ?string
{
return $this->password;
}
public function getEmail(): string
{
return $this->email;
}
public function setEmail(string $email): void
{
$this->email = $email;
}
public function setRole(AdministratorRole $role): void
{
$this->role = $role;
}
public function isActive(): bool
{
return $this->active;
}
public function setActive(bool $active): void
{
$this->active = $active;
}
}