src/Entity/Name.php line 13

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. /**
  7.  * @ORM\Embeddable()
  8.  */
  9. class Name
  10. {
  11.     /**
  12.      * @ORM\Column(type="string", nullable=true)
  13.      * @Assert\NotBlank(
  14.      *     message="お名前(名)を入力してください",
  15.      *     groups="guest"
  16.      * )
  17.      * @Assert\Length(
  18.      *     max=100
  19.      * )
  20.      */
  21.     private ?string $first null;
  22.     /**
  23.      * @ORM\Column(type="string", nullable=true)
  24.      * @Assert\NotBlank(
  25.      *     message="お名前(姓)を入力してください",
  26.      *     groups="guest"
  27.      * )
  28.      * @Assert\Length(
  29.      *     max=100
  30.      * )
  31.      */
  32.     private ?string $last null;
  33.     public function getFirst(): ?string
  34.     {
  35.         return $this->first;
  36.     }
  37.     public function setFirst(?string $first): Name
  38.     {
  39.         $this->first $first;
  40.         return $this;
  41.     }
  42.     public function getLast(): ?string
  43.     {
  44.         return $this->last;
  45.     }
  46.     public function setLast(?string $last): Name
  47.     {
  48.         $this->last $last;
  49.         return $this;
  50.     }
  51.     public function __toString(): string
  52.     {
  53.         return "{$this->last} {$this->first}";
  54.     }
  55. }