src/Entity/PhoneValidation.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\PhoneValidationRepository")
  8.  */
  9. class PhoneValidation
  10. {
  11.     /**
  12.      * @ORM\Id()
  13.      * @ORM\GeneratedValue()
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="string", length=25)
  19.      */
  20.     private $phonenumber;
  21.     /**
  22.      * @ORM\Column(type="datetime")
  23.      */
  24.     private $created;
  25.     /**
  26.      * @ORM\Column(type="datetime", nullable=true)
  27.      */
  28.     private $dateConfirmation;
  29.     /**
  30.      * @ORM\Column(type="string", length=50, nullable=true)
  31.      */
  32.     private $token;
  33.     /**
  34.      * @ORM\OneToMany(targetEntity="App\Entity\Prospect", mappedBy="phoneValidation")
  35.      */
  36.     private $prospect;
  37.     /**
  38.      * Représente l'entité par défault
  39.      * @return string
  40.      */
  41.     public function __toString(){
  42.         return 'PhoneValidation '.$this->getPhonenumber().' ['.$this->getId().']';
  43.     }
  44.     /**
  45.      * Représente l'entité dans le BO
  46.      * @return string
  47.      */
  48.     public function getLabel(){
  49.         return $this->getPhonenumber();
  50.     }
  51.     public function __construct()
  52.     {
  53.         $this->prospect = new ArrayCollection();
  54.         $this->created = new \DateTime('NOW');
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getPhonenumber(): ?string
  61.     {
  62.         return $this->phonenumber;
  63.     }
  64.     public function setPhonenumber(string $phonenumber): self
  65.     {
  66.         $this->phonenumber $phonenumber;
  67.         return $this;
  68.     }
  69.     public function getCreated(): ?\DateTimeInterface
  70.     {
  71.         return $this->created;
  72.     }
  73.     public function setCreated(\DateTimeInterface $created): self
  74.     {
  75.         $this->created $created;
  76.         return $this;
  77.     }
  78.     public function getDateConfirmation(): ?\DateTimeInterface
  79.     {
  80.         return $this->dateConfirmation;
  81.     }
  82.     public function setDateConfirmation(\DateTimeInterface $dateConfirmation): self
  83.     {
  84.         $this->dateConfirmation $dateConfirmation;
  85.         return $this;
  86.     }
  87.     public function getToken(): ?string
  88.     {
  89.         return $this->token;
  90.     }
  91.     public function setToken(?string $token): self
  92.     {
  93.         $this->token $token;
  94.         return $this;
  95.     }
  96.     /**
  97.      * @return Collection|Prospect[]
  98.      */
  99.     public function getProspect(): Collection
  100.     {
  101.         return $this->prospect;
  102.     }
  103.     public function addProspect(Prospect $prospect): self
  104.     {
  105.         if (!$this->prospect->contains($prospect)) {
  106.             $this->prospect[] = $prospect;
  107.             $prospect->setPhoneValidation($this);
  108.         }
  109.         return $this;
  110.     }
  111.     public function removeProspect(Prospect $prospect): self
  112.     {
  113.         if ($this->prospect->contains($prospect)) {
  114.             $this->prospect->removeElement($prospect);
  115.             // set the owning side to null (unless already changed)
  116.             if ($prospect->getPhoneValidation() === $this) {
  117.                 $prospect->setPhoneValidation(null);
  118.             }
  119.         }
  120.         return $this;
  121.     }
  122.     /**
  123.      */
  124.     public function isConfirmed(){
  125.         return !is_null($this->getDateConfirmation());
  126.     }
  127.     /**
  128.      * Confirm phoneNumber setting confirmation date and clearing the token
  129.      */
  130.     public function confirm(){
  131.         $this->setDateConfirmation(new \DateTime());
  132.         $this->setToken(null);
  133.     }
  134.     public function getNumberOfProspects(){
  135.         return $this->prospect->count();
  136.     }
  137. }