src/Entity/EmailBlacklist.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EmailBlacklistRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. #[ORM\Entity(repositoryClassEmailBlacklistRepository::class)]
  8. #[ORM\Table(name'email_blacklist')]
  9. #[ORM\Index(name'idx_email'columns: ['email'])]
  10. #[UniqueEntity(fields: ['email'], message'Cet email est déjà dans la blacklist.')]
  11. class EmailBlacklist
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private ?int $id null;
  17.     #[ORM\Column(type'string'length255uniquetrue)]
  18.     #[Assert\NotBlank(message'L\'email ne peut pas être vide.')]
  19.     #[Assert\Email(message'L\'email n\'est pas valide.')]
  20.     private ?string $email null;
  21.     #[ORM\Column(type'text'nullabletrue)]
  22.     private ?string $reason null;
  23.     #[ORM\Column(type'datetime_immutable')]
  24.     private ?\DateTimeImmutable $createdAt null;
  25.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  26.     private ?\DateTimeImmutable $updatedAt null;
  27.     #[ORM\Column(type'boolean'options: ['default' => true])]
  28.     private bool $isActive true;
  29.     #[ORM\Column(type'string'length50nullabletrue)]
  30.     private ?string $addedBy null;
  31.     #[ORM\Column(type'integer'options: ['default' => 0])]
  32.     private int $blockCount 0;
  33.     #[ORM\Column(type'string'length255)]
  34.     private $name;
  35.     public function __construct()
  36.     {
  37.         $this->createdAt = new \DateTimeImmutable();
  38.         $this->isActive true;
  39.         $this->blockCount 0;
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getEmail(): ?string
  46.     {
  47.         return $this->email;
  48.     }
  49.     public function setEmail(string $email): self
  50.     {
  51.         $this->email strtolower(trim($email));
  52.         return $this;
  53.     }
  54.     public function getReason(): ?string
  55.     {
  56.         return $this->reason;
  57.     }
  58.     public function setReason(?string $reason): self
  59.     {
  60.         $this->reason $reason;
  61.         return $this;
  62.     }
  63.     public function getCreatedAt(): ?\DateTimeImmutable
  64.     {
  65.         return $this->createdAt;
  66.     }
  67.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  68.     {
  69.         $this->createdAt $createdAt;
  70.         return $this;
  71.     }
  72.     public function getUpdatedAt(): ?\DateTimeImmutable
  73.     {
  74.         return $this->updatedAt;
  75.     }
  76.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
  77.     {
  78.         $this->updatedAt $updatedAt;
  79.         return $this;
  80.     }
  81.     public function isActive(): bool
  82.     {
  83.         return $this->isActive;
  84.     }
  85.     public function setIsActive(bool $isActive): self
  86.     {
  87.         $this->isActive $isActive;
  88.         return $this;
  89.     }
  90.     public function getAddedBy(): ?string
  91.     {
  92.         return $this->addedBy;
  93.     }
  94.     public function setAddedBy(?string $addedBy): self
  95.     {
  96.         $this->addedBy $addedBy;
  97.         return $this;
  98.     }
  99.     public function getBlockCount(): int
  100.     {
  101.         return $this->blockCount;
  102.     }
  103.     public function setBlockCount(int $blockCount): self
  104.     {
  105.         $this->blockCount $blockCount;
  106.         return $this;
  107.     }
  108.     public function incrementBlockCount(): self
  109.     {
  110.         $this->blockCount++;
  111.         $this->updatedAt = new \DateTimeImmutable();
  112.         return $this;
  113.     }
  114.     public function __toString(): string
  115.     {
  116.         return $this->email ?? '';
  117.     }
  118.     public function getName(): ?string
  119.     {
  120.         return $this->name;
  121.     }
  122.     public function setName(string $name): self
  123.     {
  124.         $this->name $name;
  125.         return $this;
  126.     }
  127. }