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
<?php
namespace App\Entity ;
use App\Repository\AddressRepository ;
use Doctrine\ORM\Mapping as ORM ;
use Gedmo\Timestampable\Traits\TimestampableEntity ;
use Symfony\Component\Serializer\Annotation\Groups ;
use Symfony\Component\Validator\Constraints as Assert ;
use Symfony\Component\Validator\Context\ExecutionContextInterface ;
#[ORM\Entity ( repositoryClass : AddressRepository ::class)]
class Address
{
use TimestampableEntity ;
#[ORM\Id ]
#[ORM\GeneratedValue ]
#[ORM\Column ]
private ?int $id = null ;
#[ORM\Column ( length : 255 )]
#[Assert\NotBlank ]
private ?string $addressName = null ;
#[ORM\Column ( length : 255 )]
#[Assert\NotBlank ]
private ?string $lastname = null ;
#[ORM\Column ( length : 255 )]
#[Assert\NotBlank ]
private ?string $firstname = null ;
#[ORM\Column ( length : 255 )]
#[Assert\NotBlank ]
#[Groups ([ 'post_invoice' ])]
private ?string $address = null ;
#[ORM\Column ( length : 255 , nullable : true )]
#[Groups ([ 'post_invoice' ])]
private ?string $address_line1 = null ;
#[ORM\Column ( length : 255 , nullable : true )]
#[Groups ([ 'post_invoice' ])]
private ?string $address_line2 = null ;
#[ORM\Column ( length : 255 , nullable : true )]
#[Groups ([ 'post_invoice' ])]
private ?string $city = null ;
#[ORM\Column ( length : 255 , nullable : true )]
#[Groups ([ 'post_invoice' ])]
private ?string $zipcode = null ;
#[ORM\ManyToOne ( targetEntity : User ::class, inversedBy : 'addresses' )]
private ?User $user ;
#[ORM\Column ( type : 'json' , nullable : true )]
private ?array $interenchereAddress = null ;
#[ORM\ManyToOne ]
#[Groups ([ 'post_invoice' ])]
private ?Country $country = null ;
#[ORM\ManyToOne ]
#[Groups ([ 'post_invoice' ])]
private ?Region $region = null ;
#[Assert\Callback ]
public function validate ( ExecutionContextInterface $context , mixed $payload ): void
{
if ($this -> getRegion () && $this -> getCountry ()) {
if ($this -> getRegion ()-> getCountry () !== $this -> getCountry ()) {
$context -> buildViolation ( 'La région doit faire partie du pays sélectionné' )-> atPath ( 'region' )-> addViolation ();
}
}
}
public function getId (): ? int
{
return $this -> id ;
}
public function getAddressName (): ? string
{
return $this -> addressName ;
}
public function setAddressName (? string $addressName ): self
{
$this -> addressName = $addressName ;
return $this ;
}
public function getLastname (): ? string
{
return $this -> lastname ;
}
public function setLastname (? string $lastname ): self
{
$this -> lastname = $lastname ;
return $this ;
}
public function getFirstname (): ? string
{
return $this -> firstname ;
}
public function setFirstname (? string $firstname ): self
{
$this -> firstname = $firstname ;
return $this ;
}
public function getAddress (): ? string
{
return $this -> address ;
}
public function setAddress (? string $address ): self
{
$this -> address = $address ;
return $this ;
}
/**
* @return string|null
*/
public function getAddressLine1 (): ? string
{
return $this -> address_line1 ;
}
/**
* @param string|null $address_line1
* @return Address
*/
public function setAddressLine1 (? string $address_line1 ): Address
{
$this -> address_line1 = $address_line1 ;
return $this ;
}
/**
* @return string|null
*/
public function getAddressLine2 (): ? string
{
return $this -> address_line2 ;
}
/**
* @param string|null $address_line2
* @return Address
*/
public function setAddressLine2 (? string $address_line2 ): Address
{
$this -> address_line2 = $address_line2 ;
return $this ;
}
public function getUser (): ? User
{
return $this -> user ;
}
public function setUser (? User $user ): self
{
$this -> user = $user ;
return $this ;
}
public function __toString (): string
{
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 ();
}
public function getAddressLines (): string
{
return join ( ', ' , array_filter ([ $this -> address , $this -> address_line1 , $this -> address_line2 ], fn( $v ) => $v ));
}
public function getCityZipcodeCountry (): string
{
return join ( ' ' , array_filter ([ $this -> zipcode , $this -> city ], fn( $v ) => $v )) . ( $this -> country ? ', ' . $this -> country -> getLocalizedName () : '' );
}
public function __toJson (): array
{
return array(
'lastname' => $this -> lastname ,
'firstname' => $this -> firstname ,
'fullname' => $this -> getFullname (),
'address' => $this -> address ,
'address_line1' => $this -> address_line1 ,
'address_line2' => $this -> address_line2 ,
'zipcode' => $this -> getZipcode (),
'city' => $this -> getCity (),
'country' => $this -> getCountry ()-> getName (),
'countryCode' => $this -> getCountry ()-> getCode (),
'id' => $this -> getId (),
);
}
public static function isJsonComplete (array $address ): bool
{
return count ( array_filter ( $address )) === count ( array_keys ( $address ));
}
public function getFullname (): string
{
return join ( ' ' , [ $this -> firstname , $this -> lastname ]);
}
public function getInterenchereAddress (): ?array
{
return $this -> interenchereAddress ;
}
public function setInterenchereAddress (array $interenchereAddress ): self
{
$this -> interenchereAddress = $interenchereAddress ;
return $this ;
}
/**
* @return string|null
*/
public function getZipcode (): ? string
{
return $this -> zipcode ;
}
/**
* @param string|null $zipcode
*/
public function setZipcode (? string $zipcode ): void
{
$this -> zipcode = $zipcode ;
}
public function getCountry (): ? Country
{
return $this -> country ;
}
public function setCountry (? Country $country ): self
{
$this -> country = $country ;
return $this ;
}
/**
* @return string|null
*/
public function getCity (): ? string
{
return $this -> city ;
}
/**
* @param string|null $city
*/
public function setCity (? string $city ): void
{
$this -> city = $city ;
}
public function isComplete (): bool
{
return $this -> getCity () && $this -> getZipcode () && $this -> getCountry () && $this -> getRegion ();
}
public function getRegion (): ? Region
{
return $this -> region ;
}
public function setRegion (? Region $region ): self
{
$this -> region = $region ;
return $this ;
}
}