src/Database/Domain/Entity/User/UserProfile.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Database\Domain\Entity\User;
  3. use App\Database\Domain\Entity\AbstractEntity;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\Entity()
  9.  *
  10.  * @UniqueEntity(fields={"email"}, message="User already exists.")
  11.  */
  12. class UserProfile extends AbstractEntity
  13. {
  14.     public const REGISTRATION_TYPE_SITE 'site';
  15.     public const REGISTRATION_TYPE_GOOGLE 'google';
  16.     public const REGISTRATION_TYPE_FACEBOOK 'facebook';
  17.     public const REGISTRATION_TYPE_APPLE 'apple';
  18.     public const REGISTRATION_TYPE_NONE 'none';
  19.     /**
  20.      * @ORM\Column(type="string", nullable=true, unique=false)
  21.      *
  22.      * @Assert\Length(max="255")
  23.      */
  24.     private ?string $email;
  25.     /**
  26.      * @ORM\Column(type="boolean")
  27.      */
  28.     private bool $emailConfirmed;
  29.     /**
  30.      * @ORM\Column(type="string", nullable=false)
  31.      *
  32.      * @Assert\Choice(choices={
  33.      *     UserProfile::REGISTRATION_TYPE_FACEBOOK,
  34.      *     UserProfile::REGISTRATION_TYPE_GOOGLE,
  35.      *     UserProfile::REGISTRATION_TYPE_SITE,
  36.      *     UserProfile::REGISTRATION_TYPE_APPLE,
  37.      *     UserProfile::REGISTRATION_TYPE_NONE
  38.      *  }, message="Invalid registration type")
  39.      */
  40.     private string $registrationType;
  41.     /**
  42.      * @ORM\Column(type="string", nullable=true)
  43.      *
  44.      * @Assert\Length(max="255")
  45.      */
  46.     private ?string $name;
  47.     /**
  48.      * @ORM\Column(type="string", nullable=true)
  49.      *
  50.      * @Assert\Length(max="255")
  51.      */
  52.     private ?string $surname;
  53.     /**
  54.      * @ORM\Column(type="string", nullable=true)
  55.      */
  56.     private ?string $profession null;
  57.     public function __construct(
  58.         string $id,
  59.         ?string $name null,
  60.         ?string $email null,
  61.         ?string $surname null,
  62.         string $registrationType self::REGISTRATION_TYPE_NONE,
  63.         bool $emailConfirmed false
  64.     ) {
  65.         $this->id $id;
  66.         $this->name $name;
  67.         $this->surname $surname;
  68.         $this->email $email;
  69.         $this->registrationType $registrationType;
  70.         $this->emailConfirmed $emailConfirmed;
  71.     }
  72.     public function getName(): ?string
  73.     {
  74.         return $this->name;
  75.     }
  76.     public function setName(?string $name): self
  77.     {
  78.         $this->name $name;
  79.         return $this;
  80.     }
  81.     public function getSurname(): ?string
  82.     {
  83.         return $this->surname;
  84.     }
  85.     public function setSurname(?string $surname): self
  86.     {
  87.         $this->surname $surname;
  88.         return $this;
  89.     }
  90.     public function getEmail(): ?string
  91.     {
  92.         return $this->email;
  93.     }
  94.     public function setEmail(?string $email): self
  95.     {
  96.         $this->email $email;
  97.         return $this;
  98.     }
  99.     public function isEmailConfirmed(): bool
  100.     {
  101.         return $this->emailConfirmed;
  102.     }
  103.     public function setEmailConfirmed(bool $emailConfirmed): self
  104.     {
  105.         $this->emailConfirmed $emailConfirmed;
  106.         return $this;
  107.     }
  108.     public function getRegistrationType(): string
  109.     {
  110.         return $this->registrationType;
  111.     }
  112.     public function setRegistrationType(string $registrationType): self
  113.     {
  114.         $this->registrationType $registrationType;
  115.         return $this;
  116.     }
  117.     public function isSiteRegistered(): bool
  118.     {
  119.         return $this->registrationType === self::REGISTRATION_TYPE_SITE;
  120.     }
  121.     public function isGoogleRegistered(): bool
  122.     {
  123.         return $this->registrationType === self::REGISTRATION_TYPE_GOOGLE;
  124.     }
  125.     public function isFacebookRegistered(): bool
  126.     {
  127.         return $this->registrationType === self::REGISTRATION_TYPE_FACEBOOK;
  128.     }
  129.     public function getProfession(): ?string
  130.     {
  131.         return $this->profession;
  132.     }
  133.     public function setProfession(?string $profession): void
  134.     {
  135.         $this->profession $profession;
  136.     }
  137. }