Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

src/Entity/Address.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AddressRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Timestampable\Traits\TimestampableEntity;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  9. #[ORM\Entity(repositoryClassAddressRepository::class)]
  10. class Address
  11. {
  12.     use TimestampableEntity;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     #[Assert\NotBlank]
  19.     private ?string $addressName null;
  20.     #[ORM\Column(length255)]
  21.     #[Assert\NotBlank]
  22.     private ?string $lastname null;
  23.     #[ORM\Column(length255)]
  24.     #[Assert\NotBlank]
  25.     private ?string $firstname null;
  26.     #[ORM\Column(length255)]
  27.     #[Assert\NotBlank]
  28.     #[Groups(['post_invoice'])]
  29.     private ?string $address null;
  30.     #[ORM\Column(length255nullabletrue)]
  31.     #[Groups(['post_invoice'])]
  32.     private ?string $address_line1 null;
  33.     #[ORM\Column(length255nullabletrue)]
  34.     #[Groups(['post_invoice'])]
  35.     private ?string $address_line2 null;
  36.     #[ORM\Column(length255nullabletrue)]
  37.     #[Groups(['post_invoice'])]
  38.     private ?string $city null;
  39.     #[ORM\Column(length255nullabletrue)]
  40.     #[Groups(['post_invoice'])]
  41.     private ?string $zipcode null;
  42.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'addresses')]
  43.     private ?User $user;
  44.     #[ORM\Column(type'json'nullabletrue)]
  45.     private ?array $interenchereAddress null;
  46.     #[ORM\ManyToOne]
  47.     #[Groups(['post_invoice'])]
  48.     private ?Country $country null;
  49.     #[ORM\ManyToOne]
  50.     #[Groups(['post_invoice'])]
  51.     private ?Region $region null;
  52.     #[Assert\Callback]
  53.     public function validate(ExecutionContextInterface $contextmixed $payload): void
  54.     {
  55.         if ($this->getRegion() && $this->getCountry()) {
  56.             if ($this->getRegion()->getCountry() !== $this->getCountry()) {
  57.                 $context->buildViolation('La région doit faire partie du pays sélectionné')->atPath('region')->addViolation();
  58.             }
  59.         }
  60.     }
  61.     public function getId(): ?int
  62.     {
  63.         return $this->id;
  64.     }
  65.     public function getAddressName(): ?string
  66.     {
  67.         return $this->addressName;
  68.     }
  69.     public function setAddressName(?string $addressName): self
  70.     {
  71.         $this->addressName $addressName;
  72.         return $this;
  73.     }
  74.     public function getLastname(): ?string
  75.     {
  76.         return $this->lastname;
  77.     }
  78.     public function setLastname(?string $lastname): self
  79.     {
  80.         $this->lastname $lastname;
  81.         return $this;
  82.     }
  83.     public function getFirstname(): ?string
  84.     {
  85.         return $this->firstname;
  86.     }
  87.     public function setFirstname(?string $firstname): self
  88.     {
  89.         $this->firstname $firstname;
  90.         return $this;
  91.     }
  92.     public function getAddress(): ?string
  93.     {
  94.         return $this->address;
  95.     }
  96.     public function setAddress(?string $address): self
  97.     {
  98.         $this->address $address;
  99.         return $this;
  100.     }
  101.     /**
  102.      * @return string|null
  103.      */
  104.     public function getAddressLine1(): ?string
  105.     {
  106.         return $this->address_line1;
  107.     }
  108.     /**
  109.      * @param string|null $address_line1
  110.      * @return Address
  111.      */
  112.     public function setAddressLine1(?string $address_line1): Address
  113.     {
  114.         $this->address_line1 $address_line1;
  115.         return $this;
  116.     }
  117.     /**
  118.      * @return string|null
  119.      */
  120.     public function getAddressLine2(): ?string
  121.     {
  122.         return $this->address_line2;
  123.     }
  124.     /**
  125.      * @param string|null $address_line2
  126.      * @return Address
  127.      */
  128.     public function setAddressLine2(?string $address_line2): Address
  129.     {
  130.         $this->address_line2 $address_line2;
  131.         return $this;
  132.     }
  133.     public function getUser(): ?User
  134.     {
  135.         return $this->user;
  136.     }
  137.     public function setUser(?User $user): self
  138.     {
  139.         $this->user $user;
  140.         return $this;
  141.     }
  142.     public function __toString(): string
  143.     {
  144.         return $this->lastname ' ' $this->firstname "\n" $this->address "\n" . ($this->address_line1 $this->address_line1 "\n" '') . ($this->address_line2 $this->address_line2 "\n" '') . ", " $this->getZipcode() . " " $this->getCity() . " " $this->getCountry()?->getName();
  145.     }
  146.     public function getAddressLines(): string
  147.     {
  148.         return join(', 'array_filter([$this->address$this->address_line1$this->address_line2], fn($v) => $v));
  149.     }
  150.     public function getCityZipcodeCountry(): string
  151.     {
  152.         return join(' 'array_filter([$this->zipcode$this->city], fn($v) => $v)) . ($this->country ', ' $this->country->getLocalizedName() : '');
  153.     }
  154.     public function __toJson(): array
  155.     {
  156.         return array(
  157.             'lastname' => $this->lastname,
  158.             'firstname' => $this->firstname,
  159.             'fullname' => $this->getFullname(),
  160.             'address' => $this->address,
  161.             'address_line1' => $this->address_line1,
  162.             'address_line2' => $this->address_line2,
  163.             'zipcode' => $this->getZipcode(),
  164.             'city' => $this->getCity(),
  165.             'country' => $this->getCountry()->getName(),
  166.             'countryCode' => $this->getCountry()->getCode(),
  167.             'id' => $this->getId(),
  168.         );
  169.     }
  170.     public static function isJsonComplete(array $address): bool
  171.     {
  172.         return count(array_filter($address)) === count(array_keys($address));
  173.     }
  174.     public function getFullname(): string
  175.     {
  176.         return join(' ', [$this->firstname$this->lastname]);
  177.     }
  178.     public function getInterenchereAddress(): ?array
  179.     {
  180.         return $this->interenchereAddress;
  181.     }
  182.     public function setInterenchereAddress(array $interenchereAddress): self
  183.     {
  184.         $this->interenchereAddress $interenchereAddress;
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return string|null
  189.      */
  190.     public function getZipcode(): ?string
  191.     {
  192.         return $this->zipcode;
  193.     }
  194.     /**
  195.      * @param string|null $zipcode
  196.      */
  197.     public function setZipcode(?string $zipcode): void
  198.     {
  199.         $this->zipcode $zipcode;
  200.     }
  201.     public function getCountry(): ?Country
  202.     {
  203.         return $this->country;
  204.     }
  205.     public function setCountry(?Country $country): self
  206.     {
  207.         $this->country $country;
  208.         return $this;
  209.     }
  210.     /**
  211.      * @return string|null
  212.      */
  213.     public function getCity(): ?string
  214.     {
  215.         return $this->city;
  216.     }
  217.     /**
  218.      * @param string|null $city
  219.      */
  220.     public function setCity(?string $city): void
  221.     {
  222.         $this->city $city;
  223.     }
  224.     public function isComplete(): bool
  225.     {
  226.         return $this->getCity() && $this->getZipcode() && $this->getCountry() && $this->getRegion();
  227.     }
  228.     public function getRegion(): ?Region
  229.     {
  230.         return $this->region;
  231.     }
  232.     public function setRegion(?Region $region): self
  233.     {
  234.         $this->region $region;
  235.         return $this;
  236.     }
  237. }