src/Entity/Contact.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ContactRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=ContactRepository::class)
  7.  */
  8. class Contact
  9. {
  10.     /**
  11.      * @ORM\Id
  12.      * @ORM\GeneratedValue
  13.      * @ORM\Column(type="integer")
  14.      */
  15.     private $id;
  16.     /**
  17.      * @ORM\Column(type="string", length=100)
  18.      */
  19.     private $name;
  20.     /**
  21.      * @ORM\Column(type="string", length=180)
  22.      */
  23.     private $email;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $subject;
  28.     /**
  29.      * @ORM\Column(type="text")
  30.      */
  31.     private $message;
  32.     /**
  33.      * @ORM\Column(type="datetime")
  34.      */
  35.     private $createdAt;
  36.     /**
  37.      * @return int|null
  38.      */
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     /**
  44.      * @return string|null
  45.      */
  46.     public function getName(): ?string
  47.     {
  48.         return $this->name;
  49.     }
  50.     /**
  51.      * @param string $name
  52.      * @return $this
  53.      */
  54.     public function setName(string $name): self
  55.     {
  56.         $this->name $name;
  57.         return $this;
  58.     }
  59.     /**
  60.      * @return string|null
  61.      */
  62.     public function getEmail(): ?string
  63.     {
  64.         return $this->email;
  65.     }
  66.     /**
  67.      * @param string $email
  68.      * @return $this
  69.      */
  70.     public function setEmail(string $email): self
  71.     {
  72.         $this->email $email;
  73.         return $this;
  74.     }
  75.     /**
  76.      * @return string|null
  77.      */
  78.     public function getSubject(): ?string
  79.     {
  80.         return $this->subject;
  81.     }
  82.     /**
  83.      * @param string $subject
  84.      * @return $this
  85.      */
  86.     public function setSubject(string $subject): self
  87.     {
  88.         $this->subject $subject;
  89.         return $this;
  90.     }
  91.     /**
  92.      * @return string|null
  93.      */
  94.     public function getMessage(): ?string
  95.     {
  96.         return $this->message;
  97.     }
  98.     /**
  99.      * @param string $message
  100.      * @return $this
  101.      */
  102.     public function setMessage(string $message): self
  103.     {
  104.         $this->message $message;
  105.         return $this;
  106.     }
  107.     public function getTruncatedMessage(): ?string
  108.     {
  109.         $stripped strip_tags($this->message);
  110.         return strlen($stripped) > 150 substr($stripped0150) . '...' $stripped;
  111.     }
  112.     /**
  113.      * @return \DateTimeInterface|null
  114.      */
  115.     public function getCreatedAt(): ?\DateTimeInterface
  116.     {
  117.         return $this->createdAt;
  118.     }
  119.     /**
  120.      * @param \DateTimeInterface $createdAt
  121.      * @return $this
  122.      */
  123.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  124.     {
  125.         $this->createdAt $createdAt;
  126.         return $this;
  127.     }
  128.     /**
  129.      * @return string
  130.      */
  131.     public function __toString()
  132.     {
  133.         return $this->getSubject().' ('.$this->getEmail().')';
  134.     }
  135. }