<?phpnamespace App\Entity;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass="App\Repository\PhoneValidationRepository") */class PhoneValidation{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=25) */ private $phonenumber; /** * @ORM\Column(type="datetime") */ private $created; /** * @ORM\Column(type="datetime", nullable=true) */ private $dateConfirmation; /** * @ORM\Column(type="string", length=50, nullable=true) */ private $token; /** * @ORM\OneToMany(targetEntity="App\Entity\Prospect", mappedBy="phoneValidation") */ private $prospect; /** * Représente l'entité par défault * @return string */ public function __toString(){ return 'PhoneValidation '.$this->getPhonenumber().' ['.$this->getId().']'; } /** * Représente l'entité dans le BO * @return string */ public function getLabel(){ return $this->getPhonenumber(); } public function __construct() { $this->prospect = new ArrayCollection(); $this->created = new \DateTime('NOW'); } public function getId(): ?int { return $this->id; } public function getPhonenumber(): ?string { return $this->phonenumber; } public function setPhonenumber(string $phonenumber): self { $this->phonenumber = $phonenumber; return $this; } public function getCreated(): ?\DateTimeInterface { return $this->created; } public function setCreated(\DateTimeInterface $created): self { $this->created = $created; return $this; } public function getDateConfirmation(): ?\DateTimeInterface { return $this->dateConfirmation; } public function setDateConfirmation(\DateTimeInterface $dateConfirmation): self { $this->dateConfirmation = $dateConfirmation; return $this; } public function getToken(): ?string { return $this->token; } public function setToken(?string $token): self { $this->token = $token; return $this; } /** * @return Collection|Prospect[] */ public function getProspect(): Collection { return $this->prospect; } public function addProspect(Prospect $prospect): self { if (!$this->prospect->contains($prospect)) { $this->prospect[] = $prospect; $prospect->setPhoneValidation($this); } return $this; } public function removeProspect(Prospect $prospect): self { if ($this->prospect->contains($prospect)) { $this->prospect->removeElement($prospect); // set the owning side to null (unless already changed) if ($prospect->getPhoneValidation() === $this) { $prospect->setPhoneValidation(null); } } return $this; } /** */ public function isConfirmed(){ return !is_null($this->getDateConfirmation()); } /** * Confirm phoneNumber setting confirmation date and clearing the token */ public function confirm(){ $this->setDateConfirmation(new \DateTime()); $this->setToken(null); } public function getNumberOfProspects(){ return $this->prospect->count(); }}