src/V4/Model/Address/Address.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\V4\Model\Address;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use App\Model\IriNormalizableInterface;
  5. use App\Model\NormalizeAsIRITrait;
  6. use App\Model\Traits\ImportableObjectTrait;
  7. use App\V4\Model\Contact\Contact;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. class Address implements IriNormalizableInterface
  10. {
  11.     use ImportableObjectTrait;
  12.     use NormalizeAsIRITrait;
  13.     const TYPE_DELIVERY_ADDRESS 'deliveryAddress';
  14.     /**
  15.      * @ApiProperty(identifier=true)
  16.      *
  17.      * @var string
  18.      *
  19.      * @Groups({
  20.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  21.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  22.      * })
  23.      */
  24.     private $id;
  25.     /**
  26.      * @var string|null
  27.      *
  28.      * @Groups({
  29.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  30.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  31.      * })
  32.      */
  33.     private $address;
  34.     /**
  35.      * @var string|null
  36.      *
  37.      * @Groups({
  38.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  39.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  40.      * })
  41.      */
  42.     private $addressMore;
  43.     /**
  44.      * @var string|null
  45.      *
  46.      * @Groups({
  47.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  48.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  49.      * })
  50.      */
  51.     private $postalCode;
  52.     /**
  53.      * @var string|null
  54.      *
  55.      * @Groups({
  56.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  57.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  58.      * })
  59.      */
  60.     private $postalCedex;
  61.     /**
  62.      * @var string|null
  63.      *
  64.      * @Groups({
  65.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  66.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  67.      * })
  68.      */
  69.     private $city;
  70.     /**
  71.      * @var string|null
  72.      *
  73.      * @Groups({
  74.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  75.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  76.      * })
  77.      */
  78.     private $country;
  79.     /**
  80.      * @var float|null
  81.      *
  82.      * @Groups({
  83.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  84.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  85.      * })
  86.      */
  87.     private $lat;
  88.     /**
  89.      * @var float|null
  90.      *
  91.      * @Groups({
  92.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  93.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  94.      * })
  95.      */
  96.     private $lng;
  97.     /**
  98.      * @var bool|null
  99.      *
  100.      * @Groups({
  101.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  102.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  103.      * })
  104.      */
  105.     private $isGeolocated;
  106.     /**
  107.      * @var bool
  108.      *
  109.      * @Groups({
  110.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  111.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  112.      * })
  113.      */
  114.     private $isMain;
  115.     /**
  116.      * @var string|null
  117.      *
  118.      * @Groups({
  119.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  120.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  121.      * })
  122.      */
  123.     private $typeAddress;
  124.     /**
  125.      * @var Contact|null
  126.      */
  127.     private $contact;
  128.     /**
  129.      * @return string
  130.      */
  131.     public function getAddressAndAddressMore(): string
  132.     {
  133.         if (!empty($this->getAddress())) {
  134.             return $this->getAddress().(!empty($this->getAddressMore()) ? ', '.$this->getAddressMore() : '');
  135.         }
  136.         return !empty($this->getAddressMore()) ? $this->getAddressMore() : '';
  137.     }
  138.     /**
  139.      * @return string
  140.      */
  141.     public function getId(): ?string
  142.     {
  143.         return $this->id;
  144.     }
  145.     /**
  146.      * @param string $id
  147.      *
  148.      * @return Address
  149.      */
  150.     public function setId(string $id): Address
  151.     {
  152.         $this->id $id;
  153.         return $this;
  154.     }
  155.     /**
  156.      * @return string|null
  157.      */
  158.     public function getAddress(): ?string
  159.     {
  160.         return $this->address;
  161.     }
  162.     /**
  163.      * @param string|null $address
  164.      *
  165.      * @return Address
  166.      */
  167.     public function setAddress(?string $address): Address
  168.     {
  169.         $this->address $address;
  170.         return $this;
  171.     }
  172.     /**
  173.      * @return string|null
  174.      */
  175.     public function getAddressMore(): ?string
  176.     {
  177.         return $this->addressMore;
  178.     }
  179.     /**
  180.      * @param string|null $addressMore
  181.      *
  182.      * @return $this
  183.      */
  184.     public function setAddressMore(?string $addressMore): self
  185.     {
  186.         $this->addressMore $addressMore;
  187.         return $this;
  188.     }
  189.     /**
  190.      * @return string|null
  191.      */
  192.     public function getPostalCode(): ?string
  193.     {
  194.         return $this->postalCode;
  195.     }
  196.     /**
  197.      * @param string|null $postalCode
  198.      *
  199.      * @return $this
  200.      */
  201.     public function setPostalCode(?string $postalCode): self
  202.     {
  203.         $this->postalCode trim(str_replace(' '''$postalCode));
  204.         return $this;
  205.     }
  206.     /**
  207.      * @return string|null
  208.      */
  209.     public function getPostalCedex(): ?string
  210.     {
  211.         return $this->postalCedex;
  212.     }
  213.     /**
  214.      * @param string|null $postalCedex
  215.      *
  216.      * @return $this
  217.      */
  218.     public function setPostalCedex(?string $postalCedex): self
  219.     {
  220.         $this->postalCedex $postalCedex;
  221.         return $this;
  222.     }
  223.     /**
  224.      * @return string|null
  225.      */
  226.     public function getCity(): ?string
  227.     {
  228.         return $this->city;
  229.     }
  230.     /**
  231.      * @param string|null $city
  232.      *
  233.      * @return $this
  234.      */
  235.     public function setCity(?string $city): self
  236.     {
  237.         $this->city $city;
  238.         return $this;
  239.     }
  240.     /**
  241.      * @return string|null
  242.      */
  243.     public function getCountry(): ?string
  244.     {
  245.         return $this->country;
  246.     }
  247.     /**
  248.      * @param string|null $country
  249.      *
  250.      * @return $this
  251.      */
  252.     public function setCountry(?string $country): self
  253.     {
  254.         $this->country $country;
  255.         return $this;
  256.     }
  257.     /**
  258.      * @return float|null
  259.      */
  260.     public function getLat(): ?float
  261.     {
  262.         return $this->lat;
  263.     }
  264.     /**
  265.      * @param float|null $lat
  266.      *
  267.      * @return $this
  268.      */
  269.     public function setLat(?float $lat): self
  270.     {
  271.         $this->lat $lat;
  272.         return $this;
  273.     }
  274.     /**
  275.      * @return float|null
  276.      */
  277.     public function getLng(): ?float
  278.     {
  279.         return $this->lng;
  280.     }
  281.     /**
  282.      * @param float|null $lng
  283.      *
  284.      * @return $this
  285.      */
  286.     public function setLng(?float $lng): self
  287.     {
  288.         $this->lng $lng;
  289.         return $this;
  290.     }
  291.     /**
  292.      * @return bool|null
  293.      */
  294.     public function getisGeolocated(): ?bool
  295.     {
  296.         return $this->isGeolocated;
  297.     }
  298.     /**
  299.      * @param bool|null $isGeolocated
  300.      *
  301.      * @return $this
  302.      */
  303.     public function setIsGeolocated(?bool $isGeolocated): self
  304.     {
  305.         $this->isGeolocated $isGeolocated;
  306.         return $this;
  307.     }
  308.     /**
  309.      * @return bool|null
  310.      */
  311.     public function isMain(): ?bool
  312.     {
  313.         return $this->isMain;
  314.     }
  315.     /**
  316.      * @param bool|null $isMain
  317.      *
  318.      * @return $this
  319.      */
  320.     public function setIsMain(?bool $isMain): self
  321.     {
  322.         $this->isMain $isMain;
  323.         return $this;
  324.     }
  325.     /**
  326.      * @return Contact|null
  327.      */
  328.     public function getContact(): ?Contact
  329.     {
  330.         return $this->contact;
  331.     }
  332.     /**
  333.      * @param Contact|null $contact
  334.      *
  335.      * @return Address
  336.      */
  337.     public function setContact(?Contact $contact): Address
  338.     {
  339.         $this->contact $contact;
  340.         return $this;
  341.     }
  342.     /**
  343.      * @return string|null
  344.      */
  345.     public function getTypeAddress(): ?string
  346.     {
  347.         return $this->typeAddress;
  348.     }
  349.     /**
  350.      * @param string|null $typeAddress
  351.      *
  352.      * @return Address
  353.      */
  354.     public function setTypeAddress(?string $typeAddress): Address
  355.     {
  356.         $this->typeAddress $typeAddress;
  357.         return $this;
  358.     }
  359.     /**
  360.      * {@inheritdoc}
  361.      */
  362.     public function __toString()
  363.     {
  364.         return $this->getAddress().' - '.$this->getCity().' - '.$this->getPostalCode();
  365.     }
  366. }