src/Entity/EmailRecipient.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EmailRecipientRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassEmailRecipientRepository::class)]
  8. #[ORM\Table(name'email_message_recipients')]
  9. class EmailRecipient extends BaseEntity
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private ?int $id null;
  15.     #[ORM\ManyToOne(targetEntityEmailMessage::class, inversedBy'recipients')]
  16.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  17.     private ?EmailMessage $emailMessage null;
  18.     #[ORM\Column(length255)]
  19.     private string $recipientEmail;
  20.     #[ORM\Column(length64uniquetrue)]
  21.     private string $openToken;
  22.     #[ORM\Column(type'boolean')]
  23.     private bool $opened false;
  24.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  25.     private ?\DateTimeImmutable $firstOpenedAt null;
  26.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  27.     private ?\DateTimeImmutable $lastOpenedAt null;
  28.     #[ORM\Column(type'integer')]
  29.     private int $openCount 0;
  30.     #[ORM\Column(length255nullabletrue)]
  31.     private ?string $lastOpenedIpHash null;
  32.     #[ORM\Column(length512nullabletrue)]
  33.     private ?string $lastOpenedUserAgent null;
  34.     /**
  35.      * @var Collection<int, EmailOpenEvent>
  36.      */
  37.     #[ORM\OneToMany(mappedBy'recipient'targetEntityEmailOpenEvent::class, cascade: ['persist'], orphanRemovaltrue)]
  38.     private Collection $openEvents;
  39.     public function __construct()
  40.     {
  41.         $this->openEvents = new ArrayCollection();
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getEmailMessage(): ?EmailMessage
  48.     {
  49.         return $this->emailMessage;
  50.     }
  51.     public function setEmailMessage(?EmailMessage $emailMessage): self
  52.     {
  53.         $this->emailMessage $emailMessage;
  54.         return $this;
  55.     }
  56.     public function getRecipientEmail(): string
  57.     {
  58.         return $this->recipientEmail;
  59.     }
  60.     public function setRecipientEmail(string $recipientEmail): self
  61.     {
  62.         $this->recipientEmail $recipientEmail;
  63.         return $this;
  64.     }
  65.     public function getOpenToken(): string
  66.     {
  67.         return $this->openToken;
  68.     }
  69.     public function setOpenToken(string $openToken): self
  70.     {
  71.         $this->openToken $openToken;
  72.         return $this;
  73.     }
  74.     public function isOpened(): bool
  75.     {
  76.         return $this->opened;
  77.     }
  78.     public function setOpened(bool $opened): self
  79.     {
  80.         $this->opened $opened;
  81.         return $this;
  82.     }
  83.     public function getFirstOpenedAt(): ?\DateTimeImmutable
  84.     {
  85.         return $this->firstOpenedAt;
  86.     }
  87.     public function setFirstOpenedAt(?\DateTimeImmutable $firstOpenedAt): self
  88.     {
  89.         $this->firstOpenedAt $firstOpenedAt;
  90.         return $this;
  91.     }
  92.     public function getLastOpenedAt(): ?\DateTimeImmutable
  93.     {
  94.         return $this->lastOpenedAt;
  95.     }
  96.     public function setLastOpenedAt(?\DateTimeImmutable $lastOpenedAt): self
  97.     {
  98.         $this->lastOpenedAt $lastOpenedAt;
  99.         return $this;
  100.     }
  101.     public function getOpenCount(): int
  102.     {
  103.         return $this->openCount;
  104.     }
  105.     public function setOpenCount(int $openCount): self
  106.     {
  107.         $this->openCount $openCount;
  108.         return $this;
  109.     }
  110.     public function incrementOpenCount(): self
  111.     {
  112.         $this->openCount++;
  113.         return $this;
  114.     }
  115.     public function getLastOpenedIpHash(): ?string
  116.     {
  117.         return $this->lastOpenedIpHash;
  118.     }
  119.     public function setLastOpenedIpHash(?string $lastOpenedIpHash): self
  120.     {
  121.         $this->lastOpenedIpHash $lastOpenedIpHash;
  122.         return $this;
  123.     }
  124.     public function getLastOpenedUserAgent(): ?string
  125.     {
  126.         return $this->lastOpenedUserAgent;
  127.     }
  128.     public function setLastOpenedUserAgent(?string $lastOpenedUserAgent): self
  129.     {
  130.         $this->lastOpenedUserAgent $lastOpenedUserAgent;
  131.         return $this;
  132.     }
  133.     /**
  134.      * @return Collection<int, EmailOpenEvent>
  135.      */
  136.     public function getOpenEvents(): Collection
  137.     {
  138.         return $this->openEvents;
  139.     }
  140.     public function addOpenEvent(EmailOpenEvent $openEvent): self
  141.     {
  142.         if (!$this->openEvents->contains($openEvent)) {
  143.             $this->openEvents->add($openEvent);
  144.             $openEvent->setRecipient($this);
  145.         }
  146.         return $this;
  147.     }
  148.     public function removeOpenEvent(EmailOpenEvent $openEvent): self
  149.     {
  150.         if ($this->openEvents->removeElement($openEvent)) {
  151.             if ($openEvent->getRecipient() === $this) {
  152.                 $openEvent->setRecipient(null);
  153.             }
  154.         }
  155.         return $this;
  156.     }
  157. }