src/Entity/Address.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AddressRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use function Sodium\add;
  6. #[ORM\Embeddable]
  7. class Address
  8. {
  9.     #[ORM\Column(type'string'length15nullabletrue)]
  10.     private $number;
  11.     #[ORM\Column(type'string'length100nullabletrue)]
  12.     private $street;
  13.     #[ORM\Column(type'string'length15nullabletrue)]
  14.     private $streetType;
  15.     #[ORM\Column(type'string'length5nullabletrue)]
  16.     private $postalCode;
  17.     #[ORM\Column(type'string'length100nullabletrue)]
  18.     private $city;
  19.     #[ORM\Column(type'string'length255nullabletrue)]
  20.     private $additional;
  21.     #[ORM\Column(type'float'nullabletrue)]
  22.     private $latitude;
  23.     #[ORM\Column(type'float'nullabletrue)]
  24.     private $longitude;
  25.     public function getNumber(): ?string
  26.     {
  27.         return $this->number;
  28.     }
  29.     public function setNumber(?string $number): self
  30.     {
  31.         $this->number $number;
  32.         return $this;
  33.     }
  34.     public function getStreet(): ?string
  35.     {
  36.         return $this->street;
  37.     }
  38.     public function setStreet(?string $street): self
  39.     {
  40.         $this->street $street;
  41.         return $this;
  42.     }
  43.     public function getStreetType(): ?string
  44.     {
  45.         return $this->streetType;
  46.     }
  47.     public function setStreetType(?string $streetType): self
  48.     {
  49.         $this->streetType $streetType;
  50.         return $this;
  51.     }
  52.     public function getPostalCode(): ?string
  53.     {
  54.         return $this->postalCode;
  55.     }
  56.     public function setPostalCode(?string $postalCode): self
  57.     {
  58.         $this->postalCode $postalCode;
  59.         return $this;
  60.     }
  61.     public function getCity(): ?string
  62.     {
  63.         return $this->city;
  64.     }
  65.     public function setCity(?string $city): self
  66.     {
  67.         $this->city $city;
  68.         return $this;
  69.     }
  70.     public function getAdditional(): ?string
  71.     {
  72.         return $this->additional;
  73.     }
  74.     public function setAdditional(?string $additional): self
  75.     {
  76.         $this->additional $additional;
  77.         return $this;
  78.     }
  79.     public function getLatitude(): ?float
  80.     {
  81.         return $this->latitude;
  82.     }
  83.     public function setLatitude(?float $latitude): self
  84.     {
  85.         $this->latitude $latitude;
  86.         return $this;
  87.     }
  88.     public function getLongitude(): ?float
  89.     {
  90.         return $this->longitude;
  91.     }
  92.     public function setLongitude(?float $longitude): self
  93.     {
  94.         $this->longitude $longitude;
  95.         return $this;
  96.     }
  97.     public function getFullAddress(): string
  98.     {
  99.         $address '';
  100.         if ($number $this->getNumber()) {
  101.             $address .= $number;
  102.         }
  103.         if ($street $this->getStreet()) {
  104.             $address .= ' '.$street;
  105.         }
  106.         if ($postalCode $this->getPostalCode()) {
  107.             $address .= ' '.$postalCode;
  108.         }
  109.         if ($city $this->getCity()) {
  110.             $address .= ' '.$this->city;
  111.         }
  112.         $address trim($address);
  113.         return $address;
  114.     }
  115.     public function __toString(): string
  116.     {
  117.         return $this->getFullAddress();
  118.     }
  119. }