Files
myep-team/src/Entity/Embeddable/Communication.php
T
2023-09-02 18:47:42 +02:00

72 lines
1.5 KiB
PHP

<?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;
}
}