src/Entity/Embeddable/Email.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Embeddable;
  3. use Doctrine\DBAL\Types\Types;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. #[ORM\Embeddable]
  7. class Email
  8. {
  9.     #[ORM\Column(typeTypes::STRINGlength150nullabletrueoptions: ['default' => 'no-reply@localhost.com'])]
  10.     #[Gedmo\Versioned]
  11.     private ?string $from 'no-reply@localhost.com';
  12.     #[ORM\Column(typeTypes::STRINGlength150options: ['default' => 'errors@localhost.com'])]
  13.     #[Gedmo\Versioned]
  14.     private string $toError 'errors@localhost.com';
  15.     #[ORM\Column(typeTypes::STRINGlength200options: ['default' => 'smtp.localhost.com'])]
  16.     #[Gedmo\Versioned]
  17.     private string $host 'smtp.localhost.com';
  18.     #[ORM\Column(typeTypes::SMALLINToptions: ['default' => 25])]
  19.     #[Gedmo\Versioned]
  20.     private int $port 25;
  21.     #[ORM\Column(typeTypes::STRINGlength200options: ['default' => 'user@localhost.com'])]
  22.     #[Gedmo\Versioned]
  23.     private string $user 'user@localhost';
  24.     #[ORM\Column(typeTypes::STRINGlength255options: ['default' => 'password'])]
  25.     #[Gedmo\Versioned]
  26.     private string $password 'password';
  27.     public function toDsn(): string
  28.     {
  29.         return \sprintf(
  30.             'smtp://%s:%s@%s:%d',
  31.             \urlencode(!empty($this->user) ? $this->user 'user@localhost.com'),
  32.             \urlencode(!empty($this->password) ? $this->password 'password'),
  33.             \urlencode(!empty($this->host) ? $this->host 'stmp.localhost.com'),
  34.             $this->port && $this->port >= 25 $this->port 25
  35.         );
  36.     }
  37.     public function getFrom(): ?string
  38.     {
  39.         return $this->from;
  40.     }
  41.     public function setFrom(?string $from): self
  42.     {
  43.         $this->from $from;
  44.         return $this;
  45.     }
  46.     public function getToError(): ?string
  47.     {
  48.         return $this->toError;
  49.     }
  50.     public function setToError(string $toError): self
  51.     {
  52.         $this->toError $toError;
  53.         return $this;
  54.     }
  55.     public function getHost(): ?string
  56.     {
  57.         return $this->host;
  58.     }
  59.     public function setHost(string $host): self
  60.     {
  61.         $this->host $host;
  62.         return $this;
  63.     }
  64.     public function getPort(): ?int
  65.     {
  66.         return $this->port;
  67.     }
  68.     public function setPort(int $port): self
  69.     {
  70.         $this->port $port;
  71.         return $this;
  72.     }
  73.     public function getUser(): ?string
  74.     {
  75.         return $this->user;
  76.     }
  77.     public function setUser(string $user): self
  78.     {
  79.         $this->user $user;
  80.         return $this;
  81.     }
  82.     public function getPassword(): ?string
  83.     {
  84.         return $this->password;
  85.     }
  86.     public function setPassword(string $password): self
  87.     {
  88.         $this->password $password;
  89.         return $this;
  90.     }
  91. }