<?php
namespace App\Entity;
use App\Repository\AddresseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=AddresseRepository::class)
*/
class Addresse
{
const STATUT_VIDE = 0;
const STATUT_NON_GEOCODED = 1;
const STATUT_GEOCODED = 2;
const STATUT_MULTIPLE_GEOCODING_MATCHES = 3;
const STATUT_GEOCODING_ERROR = 4;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255 , nullable=true)
*/
private $Title;
/**
* @ORM\ManyToOne(targetEntity=AddressesList::class, inversedBy="addresses")
*/
private $AddressesGroup;
/**
* @ORM\Column(type="string", length=255 , nullable=true)
*/
private $address;
/**
* @ORM\Column(type="string", length=10 , nullable=true)
*/
private $zipcode;
/**
* @ORM\Column(type="string", length=100 , nullable=true)
*/
private $city;
/**
* @ORM\Column(type="integer")
*/
private $Status;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $Lat;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $Lon;
/**
* @ORM\OneToMany(targetEntity=Timing::class, mappedBy="Address")
*/
private $timings;
public function __construct()
{
$this->timings = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->Title;
}
public function setTitle(string $Title): self
{
$this->Title = $Title;
return $this;
}
public function getAddressesGroup(): ?AddressesList
{
return $this->AddressesGroup;
}
public function setAddressesGroup(?AddressesList $AddressesGroup): self
{
$this->AddressesGroup = $AddressesGroup;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getZipcode(): ?string
{
return $this->zipcode;
}
public function setZipcode(?string $zipcode): self
{
$this->zipcode = $zipcode;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getStatus(): ?int
{
return $this->Status;
}
public function setStatus(int $Status): self
{
$this->Status = $Status;
return $this;
}
public function getLat(): ?float
{
return $this->Lat;
}
public function setLat(?float $Lat): self
{
$this->Lat = $Lat;
return $this;
}
public function getLon(): ?float
{
return $this->Lon;
}
public function setLon(?float $Lon): self
{
$this->Lon = $Lon;
return $this;
}
public function toString(){
return $this->getTitle().' '.$this->getAddress().' '.$this->getZipcode().' '.$this->getCity();
}
public function getAddressLine(){
$search = [' bd ', ' BD ' , ' st ' , ' ST '];
$replace = [' boulevard ', ' BOULEVARD ',' saint ', ' SAINT ' ];
$addressLine = $this->getAddress().' '.$this->getZipcode().' '.$this->getCity();
$addressLine = str_replace($search, $replace, $addressLine);
return $addressLine;
}
public function getStatusTextInfo(){
switch ($this->getStatus())
{
case self::STATUT_VIDE: return 'Adresse vide';
case self::STATUT_GEOCODED: return 'Géocodée';
case self::STATUT_NON_GEOCODED: return 'Adresse à géocoder';
case self::STATUT_MULTIPLE_GEOCODING_MATCHES: return 'Adresse approximative ou plusieurs adresses possibles';
case self::STATUT_GEOCODING_ERROR: return 'Géocodage impossible';
}
}
public function getStatusBadgeInfo(){
switch ($this->getStatus())
{
case self::STATUT_VIDE: return 'warning';
case self::STATUT_NON_GEOCODED: return 'warning';
case self::STATUT_MULTIPLE_GEOCODING_MATCHES: return 'warning';
case self::STATUT_GEOCODED: return 'success';
case self::STATUT_GEOCODING_ERROR: return 'error';
}
}
/**
* @return Collection<int, Timing>
*/
public function getTimings(): Collection
{
return $this->timings;
}
public function addTiming(Timing $timing): self
{
if (!$this->timings->contains($timing)) {
$this->timings[] = $timing;
$timing->setAddress($this);
}
return $this;
}
public function removeTiming(Timing $timing): self
{
if ($this->timings->removeElement($timing)) {
// set the owning side to null (unless already changed)
if ($timing->getAddress() === $this) {
$timing->setAddress(null);
}
}
return $this;
}
}