src/Domain/Administrator/Model/Administrator.php line 13

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Domain\Administrator\Model;
  4. use App\Domain\Shared\Model\Aggregate;
  5. use App\Domain\Shared\Model\TimestampTrait;
  6. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use Symfony\Component\Uid\Uuid;
  9. class Administrator extends Aggregate implements UserInterfacePasswordAuthenticatedUserInterface
  10. {
  11.     use TimestampTrait;
  12.     public function __construct(
  13.         private Uuid $id,
  14.         private string $email,
  15.         private string $password,
  16.         private AdministratorRole $role,
  17.         private bool $active
  18.     ) {
  19.         $this->createdAt = new \DateTimeImmutable();
  20.         $this->updatedAt null;
  21.     }
  22.     public function getId(): Uuid
  23.     {
  24.         return $this->id;
  25.     }
  26.     public function getRoles(): array
  27.     {
  28.         return [$this->role->value];
  29.     }
  30.     public function getRole(): AdministratorRole
  31.     {
  32.         return $this->role;
  33.     }
  34.     public function eraseCredentials(): void
  35.     {
  36.         // TODO: Implement eraseCredentials() method.
  37.     }
  38.     public function getUserIdentifier(): string
  39.     {
  40.         return $this->email;
  41.     }
  42.     public function setPassword(string $password): void
  43.     {
  44.         $this->password $password;
  45.     }
  46.     public function getPassword(): ?string
  47.     {
  48.         return $this->password;
  49.     }
  50.     public function getEmail(): string
  51.     {
  52.         return $this->email;
  53.     }
  54.     public function setEmail(string $email): void
  55.     {
  56.         $this->email $email;
  57.     }
  58.     public function setRole(AdministratorRole $role): void
  59.     {
  60.         $this->role $role;
  61.     }
  62.     public function isActive(): bool
  63.     {
  64.         return $this->active;
  65.     }
  66.     public function setActive(bool $active): void
  67.     {
  68.         $this->active $active;
  69.     }
  70. }