src\Models\Contact.php line 12

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Models;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. /**
  6.  * Class Contact.
  7.  */
  8. class Contact
  9. {
  10.     /**
  11.      * @var string|null
  12.      * @Assert\NotBlank
  13.      * @Assert\Length(min="2", max="50")
  14.      */
  15.     private $name;
  16.     /**
  17.      * @var string|null
  18.      * @Assert\NotBlank
  19.      * @Assert\Length(min="2", max="50")
  20.      */
  21.     private $lastname;
  22.     /**
  23.      * @var string|null
  24.      * @Assert\NotBlank
  25.      * @Assert\Email
  26.      * @Assert\Length(min="10", max="78")
  27.      */
  28.     private $email;
  29.     /**
  30.      * @var string|null
  31.      * @Assert\Length(max="30")
  32.      */
  33.     private $phone;
  34.     /**
  35.      * @var string|null
  36.      * @Assert\NotBlank
  37.      * @Assert\Length(min="2", max="300")
  38.      */
  39.     private $message;
  40.     /**
  41.      * @var bool
  42.      */
  43.     private $acknowledgmentReceipt;
  44.     public function __construct()
  45.     {
  46.         $this->acknowledgmentReceipt false;
  47.     }
  48.     public function getName(): ?string
  49.     {
  50.         return $this->name;
  51.     }
  52.     /**
  53.      * @return Contact
  54.      */
  55.     public function setName(?string $name): self
  56.     {
  57.         $this->name $name;
  58.         return $this;
  59.     }
  60.     public function getLastname(): ?string
  61.     {
  62.         return $this->lastname;
  63.     }
  64.     /**
  65.      * @return Contact
  66.      */
  67.     public function setLastname(?string $lastname): self
  68.     {
  69.         $this->lastname $lastname;
  70.         return $this;
  71.     }
  72.     public function getEmail(): ?string
  73.     {
  74.         return $this->email;
  75.     }
  76.     /**
  77.      * @return Contact
  78.      */
  79.     public function setEmail(?string $email): self
  80.     {
  81.         $this->email $email;
  82.         return $this;
  83.     }
  84.     public function getPhone(): ?string
  85.     {
  86.         return $this->phone;
  87.     }
  88.     /**
  89.      * @return Contact
  90.      */
  91.     public function setPhone(?string $phone): self
  92.     {
  93.         $this->phone $phone;
  94.         return $this;
  95.     }
  96.     public function getMessage(): ?string
  97.     {
  98.         return $this->message;
  99.     }
  100.     /**
  101.      * @return Contact
  102.      */
  103.     public function setMessage(?string $message): self
  104.     {
  105.         $this->message $message;
  106.         return $this;
  107.     }
  108.     public function isAcknowledgmentReceipt(): bool
  109.     {
  110.         return $this->acknowledgmentReceipt;
  111.     }
  112.     /**
  113.      * @return Contact
  114.      */
  115.     public function setAcknowledgmentReceipt(bool $acknowledgmentReceipt): self
  116.     {
  117.         $this->acknowledgmentReceipt $acknowledgmentReceipt;
  118.         return $this;
  119.     }
  120.     public function toArray(): array
  121.     {
  122.         return [
  123.             "name" => $this->getName(),
  124.             "lastName" => $this->getLastname(),
  125.             "email" => $this->getEmail(),
  126.             "phone" => $this->getPhone(),
  127.             "message" => $this->getMessage(),
  128.             "acknowledgmentReceipt" => $this->isAcknowledgmentReceipt(),
  129.         ];
  130.     }
  131. }