WIP
This commit is contained in:
1 parent
23e66b08e8
commit
08f7836d41
21 files changed
+693
-82
No files matched your search
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Embeddable;
|
||||
|
||||
use App\BusProNet\Model\Address as BpnAddress;
|
||||
use App\BusProNet\Model\ProfileResponse;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
#[ORM\Embeddable]
|
||||
class Address
|
||||
{
|
||||
#[ORM\Column(type: 'string', nullable: true)]
|
||||
#[Assert\NotBlank(message: 'required_input')]
|
||||
protected ?string $street = null;
|
||||
|
||||
#[ORM\Column(type: 'string', nullable: true)]
|
||||
#[Assert\NotBlank(message: 'required_input')]
|
||||
protected ?string $postCode = null;
|
||||
|
||||
#[ORM\Column(type: 'string', nullable: true)]
|
||||
#[Assert\NotBlank(message: 'required_input')]
|
||||
protected ?string $city = null;
|
||||
|
||||
#[ORM\Column(type: 'string', nullable: true)]
|
||||
protected ?string $country = null;
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'street' => $this->getStreet(),
|
||||
'post_code' => $this->getPostCode(),
|
||||
'city' => $this->getCity(),
|
||||
'country' => $this->getCountry(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function fromApiResponse(ProfileResponse $profileResponse): static
|
||||
{
|
||||
$address = $profileResponse->getAddress();
|
||||
|
||||
$instance = new static();
|
||||
$instance
|
||||
->setStreet($address->getStreet())
|
||||
->setPostCode($address->getPostCode())
|
||||
->setCity($address->getCity())
|
||||
->setCountry($address->getCountry() ?? 'DE')
|
||||
;
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getStreet(): ?string
|
||||
{
|
||||
return $this->street;
|
||||
}
|
||||
|
||||
public function setStreet(?string $street): static
|
||||
{
|
||||
$this->street = $street;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostCode(): ?string
|
||||
{
|
||||
return $this->postCode;
|
||||
}
|
||||
|
||||
public function setPostCode(?string $postCode): static
|
||||
{
|
||||
$this->postCode = $postCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCity(): ?string
|
||||
{
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
public function setCity(?string $city): static
|
||||
{
|
||||
$this->city = $city;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountry(): ?string
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
public function setCountry(?string $country): static
|
||||
{
|
||||
$this->country = $country;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Embeddable;
|
||||
|
||||
use App\BusProNet\Model\ProfileResponse;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
#[ORM\Embeddable]
|
||||
class Communication
|
||||
{
|
||||
#[ORM\Column(type: 'string', nullable: true)]
|
||||
protected ?string $phone = null;
|
||||
|
||||
#[ORM\Column(type: 'string', nullable: true)]
|
||||
protected ?string $mobile = null;
|
||||
|
||||
#[ORM\Column(type: 'string', nullable: true)]
|
||||
#[Assert\Email(mode: 'strict')]
|
||||
protected ?string $email = null;
|
||||
|
||||
public static function fromApiResponse(ProfileResponse $profileResponse): static
|
||||
{
|
||||
$communication = $profileResponse->getCommunication();
|
||||
|
||||
$instance = new static();
|
||||
$instance
|
||||
->setPhone($communication->getPhone())
|
||||
->setMobile($communication->getMobile())
|
||||
->setEmail($communication->getEmail())
|
||||
;
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getPhone(): ?string
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
public function setPhone(?string $phone): static
|
||||
{
|
||||
$this->phone = $phone;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMobile(): ?string
|
||||
{
|
||||
return $this->mobile;
|
||||
}
|
||||
|
||||
public function setMobile(?string $mobile): static
|
||||
{
|
||||
$this->mobile = $mobile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(?string $email): static
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Embeddable;
|
||||
|
||||
use App\BusProNet\Model\ProfileResponse;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Embeddable]
|
||||
class Profile
|
||||
{
|
||||
#[ORM\Column]
|
||||
private ?int $busProAddressId = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $busProPersonId = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $title = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $salutation = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $firstName = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $lastName = null;
|
||||
|
||||
#[ORM\Column(length: 1, nullable: true)]
|
||||
private ?string $gender = null;
|
||||
|
||||
#[ORM\Column(type: 'date_immutable', nullable: true)]
|
||||
private ?\DateTimeImmutable $dateOfBirth = null;
|
||||
|
||||
public static function fromApiResponse(ProfileResponse $profileResponse): static
|
||||
{
|
||||
$instance = new static();
|
||||
|
||||
$instance
|
||||
->setBusProAddressId($profileResponse->getAddressId())
|
||||
->setBusProPersonId($profileResponse->getPersonId())
|
||||
->setTitle($profileResponse->getTitle())
|
||||
->setSalutation($profileResponse->getSalutation())
|
||||
->setFirstName($profileResponse->getFirstName())
|
||||
->setLastName($profileResponse->getName())
|
||||
->setGender($profileResponse->getGender())
|
||||
->setDateOfBirth($profileResponse->getDateOfBirth())
|
||||
;
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
public function getBusProAddressId(): ?int
|
||||
{
|
||||
return $this->busProAddressId;
|
||||
}
|
||||
|
||||
public function setBusProAddressId(int $busProAddressId): static
|
||||
{
|
||||
$this->busProAddressId = $busProAddressId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBusProPersonId(): ?int
|
||||
{
|
||||
return $this->busProPersonId;
|
||||
}
|
||||
|
||||
public function setBusProPersonId(int $busProPersonId): static
|
||||
{
|
||||
$this->busProPersonId = $busProPersonId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSalutation(): ?string
|
||||
{
|
||||
return $this->salutation;
|
||||
}
|
||||
|
||||
public function setSalutation(?string $salutation): static
|
||||
{
|
||||
$this->salutation = $salutation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle(): ?string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(?string $title): static
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFirstName(): ?string
|
||||
{
|
||||
return $this->firstName;
|
||||
}
|
||||
|
||||
public function setFirstName(string $firstName): static
|
||||
{
|
||||
$this->firstName = $firstName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLastName(): ?string
|
||||
{
|
||||
return $this->lastName;
|
||||
}
|
||||
|
||||
public function setLastName(string $lastName): static
|
||||
{
|
||||
$this->lastName = $lastName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGender(): ?string
|
||||
{
|
||||
return $this->gender;
|
||||
}
|
||||
|
||||
public function setGender(?string $gender): static
|
||||
{
|
||||
$this->gender = $gender;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateOfBirth(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->dateOfBirth;
|
||||
}
|
||||
|
||||
public function setDateOfBirth(?\DateTimeImmutable $dateOfBirth): static
|
||||
{
|
||||
$this->dateOfBirth = $dateOfBirth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user