src/Entity/Mail.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Entity
  6.  */
  7. class Mail
  8. {
  9.     /**
  10.      * @ORM\Id
  11.      * @ORM\GeneratedValue
  12.      * @ORM\Column(type="integer")
  13.      *
  14.      * @var int
  15.      */
  16.     protected $id;
  17.     /**
  18.      * @ORM\Column(type="datetime")
  19.      *
  20.      * @var \DateTime
  21.      */
  22.     protected $date;
  23.     /**
  24.      * @ORM\Column(type="json")
  25.      *
  26.      * @var array
  27.      */
  28.     protected $recipients;
  29.     /**
  30.      * @ORM\Column(type="string")
  31.      *
  32.      * @var string
  33.      */
  34.     protected $subject;
  35.     /**
  36.      * @ORM\Column(type="text")
  37.      *
  38.      * @var string
  39.      */
  40.     protected $body;
  41.     /**
  42.      * Mail constructor.
  43.      */
  44.     public function __construct()
  45.     {
  46.         try {
  47.             $this->date = new \DateTime();
  48.         } catch (\Exception $exception) {
  49.             // If the date can't be set by default, simply ignore it
  50.         }
  51.     }
  52.     public function getId(): int
  53.     {
  54.         return $this->id;
  55.     }
  56.     /**
  57.      * @return Mail
  58.      */
  59.     public function setId(int $id): self
  60.     {
  61.         $this->id $id;
  62.         return $this;
  63.     }
  64.     public function getDate(): \DateTime
  65.     {
  66.         return $this->date;
  67.     }
  68.     /**
  69.      * @return Mail
  70.      */
  71.     public function setDate(\DateTime $date): self
  72.     {
  73.         $this->date $date;
  74.         return $this;
  75.     }
  76.     public function getRecipients(): array
  77.     {
  78.         return $this->recipients;
  79.     }
  80.     /**
  81.      * @return Mail
  82.      */
  83.     public function setRecipients(array $recipients): self
  84.     {
  85.         $this->recipients $recipients;
  86.         return $this;
  87.     }
  88.     public function getSubject(): string
  89.     {
  90.         return $this->subject;
  91.     }
  92.     /**
  93.      * @return Mail
  94.      */
  95.     public function setSubject(string $subject): self
  96.     {
  97.         $this->subject $subject;
  98.         return $this;
  99.     }
  100.     public function getBody(): string
  101.     {
  102.         return $this->body;
  103.     }
  104.     /**
  105.      * @return Mail
  106.      */
  107.     public function setBody(string $body): self
  108.     {
  109.         $this->body $body;
  110.         return $this;
  111.     }
  112.     public function getHour()
  113.     {
  114.         return $this->getDate();
  115.     }
  116.     public function getFirstRecipient(): string
  117.     {
  118.         return $this->recipients[0];
  119.     }
  120.     public function getSecondaryRecipients(): array
  121.     {
  122.         $secondaryRecipients $this->recipients;
  123.         unset($secondaryRecipients[0]);
  124.         return $secondaryRecipients;
  125.     }
  126. }