src/Entity/Addresse.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AddresseRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=AddresseRepository::class)
  9.  */
  10. class Addresse
  11. {
  12.     const  STATUT_VIDE 0;
  13.     const  STATUT_NON_GEOCODED 1;
  14.     const  STATUT_GEOCODED 2;
  15.     const  STATUT_MULTIPLE_GEOCODING_MATCHES 3;
  16.     const  STATUT_GEOCODING_ERROR 4;
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=255 , nullable=true)
  25.      */
  26.     private $Title;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity=AddressesList::class, inversedBy="addresses")
  29.      */
  30.     private $AddressesGroup;
  31.     /**
  32.      * @ORM\Column(type="string", length=255 , nullable=true)
  33.      */
  34.     private $address;
  35.     /**
  36.      * @ORM\Column(type="string", length=10 , nullable=true)
  37.      */
  38.     private $zipcode;
  39.     /**
  40.      * @ORM\Column(type="string", length=100 , nullable=true)
  41.      */
  42.     private $city;
  43.     /**
  44.      * @ORM\Column(type="integer")
  45.      */
  46.     private $Status;
  47.     /**
  48.      * @ORM\Column(type="float", nullable=true)
  49.      */
  50.     private $Lat;
  51.     /**
  52.      * @ORM\Column(type="float", nullable=true)
  53.      */
  54.     private $Lon;
  55.     /**
  56.      * @ORM\OneToMany(targetEntity=Timing::class, mappedBy="Address")
  57.      */
  58.     private $timings;
  59.     public function __construct()
  60.     {
  61.         $this->timings = new ArrayCollection();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getTitle(): ?string
  68.     {
  69.         return $this->Title;
  70.     }
  71.     public function setTitle(string $Title): self
  72.     {
  73.         $this->Title $Title;
  74.         return $this;
  75.     }
  76.     public function getAddressesGroup(): ?AddressesList
  77.     {
  78.         return $this->AddressesGroup;
  79.     }
  80.     public function setAddressesGroup(?AddressesList $AddressesGroup): self
  81.     {
  82.         $this->AddressesGroup $AddressesGroup;
  83.         return $this;
  84.     }
  85.     public function getAddress(): ?string
  86.     {
  87.         return $this->address;
  88.     }
  89.     public function setAddress(string $address): self
  90.     {
  91.         $this->address $address;
  92.         return $this;
  93.     }
  94.     public function getZipcode(): ?string
  95.     {
  96.         return $this->zipcode;
  97.     }
  98.     public function setZipcode(?string $zipcode): self
  99.     {
  100.         $this->zipcode $zipcode;
  101.         return $this;
  102.     }
  103.     public function getCity(): ?string
  104.     {
  105.         return $this->city;
  106.     }
  107.     public function setCity(?string $city): self
  108.     {
  109.         $this->city $city;
  110.         return $this;
  111.     }
  112.     public function getStatus(): ?int
  113.     {
  114.         return $this->Status;
  115.     }
  116.     public function setStatus(int $Status): self
  117.     {
  118.         $this->Status $Status;
  119.         return $this;
  120.     }
  121.     public function getLat(): ?float
  122.     {
  123.         return $this->Lat;
  124.     }
  125.     public function setLat(?float $Lat): self
  126.     {
  127.         $this->Lat $Lat;
  128.         return $this;
  129.     }
  130.     public function getLon(): ?float
  131.     {
  132.         return $this->Lon;
  133.     }
  134.     public function setLon(?float $Lon): self
  135.     {
  136.         $this->Lon $Lon;
  137.         return $this;
  138.     }
  139.     public function toString(){
  140.         return $this->getTitle().' '.$this->getAddress().' '.$this->getZipcode().' '.$this->getCity();
  141.     }
  142.     public function getAddressLine(){
  143.         $search = [' bd '' BD ' ' st ' ' ST '];
  144.         $replace = [' boulevard '' BOULEVARD ',' saint ',  ' SAINT ' ];
  145.         $addressLine $this->getAddress().' '.$this->getZipcode().' '.$this->getCity();
  146.         $addressLine str_replace($search$replace$addressLine);
  147.         return $addressLine;
  148.     }
  149.     public function getStatusTextInfo(){
  150.         switch ($this->getStatus())
  151.         {
  152.             case self::STATUT_VIDE: return 'Adresse vide';
  153.             case self::STATUT_GEOCODED: return 'Géocodée';
  154.             case self::STATUT_NON_GEOCODED: return 'Adresse à géocoder';
  155.             case self::STATUT_MULTIPLE_GEOCODING_MATCHES: return 'Adresse approximative ou plusieurs adresses possibles';
  156.             case self::STATUT_GEOCODING_ERROR: return 'Géocodage impossible';
  157.         }
  158.     }
  159.     public function getStatusBadgeInfo(){
  160.         switch ($this->getStatus())
  161.         {
  162.             case self::STATUT_VIDE: return 'warning';
  163.             case self::STATUT_NON_GEOCODED: return 'warning';
  164.             case self::STATUT_MULTIPLE_GEOCODING_MATCHES: return 'warning';
  165.             case self::STATUT_GEOCODED: return 'success';
  166.             case self::STATUT_GEOCODING_ERROR: return 'error';
  167.         }
  168.     }
  169.     /**
  170.      * @return Collection<int, Timing>
  171.      */
  172.     public function getTimings(): Collection
  173.     {
  174.         return $this->timings;
  175.     }
  176.     public function addTiming(Timing $timing): self
  177.     {
  178.         if (!$this->timings->contains($timing)) {
  179.             $this->timings[] = $timing;
  180.             $timing->setAddress($this);
  181.         }
  182.         return $this;
  183.     }
  184.     public function removeTiming(Timing $timing): self
  185.     {
  186.         if ($this->timings->removeElement($timing)) {
  187.             // set the owning side to null (unless already changed)
  188.             if ($timing->getAddress() === $this) {
  189.                 $timing->setAddress(null);
  190.             }
  191.         }
  192.         return $this;
  193.     }
  194. }