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.      * @ORM\ManyToOne(targetEntity=Instance::class)
  38.      */
  39.     private $instance;
  40.     /**
  41.      * @return int|null
  42.      */
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     /**
  48.      * @return string|null
  49.      */
  50.     public function getName(): ?string
  51.     {
  52.         return $this->name;
  53.     }
  54.     /**
  55.      * @param string $name
  56.      * @return $this
  57.      */
  58.     public function setName(string $name): self
  59.     {
  60.         $this->name $name;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return string|null
  65.      */
  66.     public function getEmail(): ?string
  67.     {
  68.         return $this->email;
  69.     }
  70.     /**
  71.      * @param string $email
  72.      * @return $this
  73.      */
  74.     public function setEmail(string $email): self
  75.     {
  76.         $this->email $email;
  77.         return $this;
  78.     }
  79.     /**
  80.      * @return string|null
  81.      */
  82.     public function getSubject(): ?string
  83.     {
  84.         return $this->subject;
  85.     }
  86.     /**
  87.      * @param string $subject
  88.      * @return $this
  89.      */
  90.     public function setSubject(string $subject): self
  91.     {
  92.         $this->subject $subject;
  93.         return $this;
  94.     }
  95.     /**
  96.      * @return string|null
  97.      */
  98.     public function getMessage(): ?string
  99.     {
  100.         return $this->message;
  101.     }
  102.     /**
  103.      * @param string $message
  104.      * @return $this
  105.      */
  106.     public function setMessage(string $message): self
  107.     {
  108.         $this->message $message;
  109.         return $this;
  110.     }
  111.     public function getTruncatedMessage(): ?string
  112.     {
  113.         $stripped strip_tags($this->message);
  114.         return strlen($stripped) > 150 substr($stripped0150) . '...' $stripped;
  115.     }
  116.     /**
  117.      * @return \DateTimeInterface|null
  118.      */
  119.     public function getCreatedAt(): ?\DateTimeInterface
  120.     {
  121.         return $this->createdAt;
  122.     }
  123.     /**
  124.      * @param \DateTimeInterface $createdAt
  125.      * @return $this
  126.      */
  127.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  128.     {
  129.         $this->createdAt $createdAt;
  130.         return $this;
  131.     }
  132.     /**
  133.      * @return string
  134.      */
  135.     public function __toString()
  136.     {
  137.         return $this->getSubject().' ('.$this->getEmail().')';
  138.     }
  139.     public function getInstance(): ?Instance
  140.     {
  141.         return $this->instance;
  142.     }
  143.     public function setInstance(?Instance $instance): self
  144.     {
  145.         $this->instance $instance;
  146.         return $this;
  147.     }
  148. }