<?php
namespace App\Database\Domain\Entity\User;
use App\Database\Domain\Entity\AbstractEntity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity()
*
* @UniqueEntity(fields={"email"}, message="User already exists.")
*/
class UserProfile extends AbstractEntity
{
public const REGISTRATION_TYPE_SITE = 'site';
public const REGISTRATION_TYPE_GOOGLE = 'google';
public const REGISTRATION_TYPE_FACEBOOK = 'facebook';
public const REGISTRATION_TYPE_APPLE = 'apple';
public const REGISTRATION_TYPE_NONE = 'none';
/**
* @ORM\Column(type="string", nullable=true, unique=false)
*
* @Assert\Length(max="255")
*/
private ?string $email;
/**
* @ORM\Column(type="boolean")
*/
private bool $emailConfirmed;
/**
* @ORM\Column(type="string", nullable=false)
*
* @Assert\Choice(choices={
* UserProfile::REGISTRATION_TYPE_FACEBOOK,
* UserProfile::REGISTRATION_TYPE_GOOGLE,
* UserProfile::REGISTRATION_TYPE_SITE,
* UserProfile::REGISTRATION_TYPE_APPLE,
* UserProfile::REGISTRATION_TYPE_NONE
* }, message="Invalid registration type")
*/
private string $registrationType;
/**
* @ORM\Column(type="string", nullable=true)
*
* @Assert\Length(max="255")
*/
private ?string $name;
/**
* @ORM\Column(type="string", nullable=true)
*
* @Assert\Length(max="255")
*/
private ?string $surname;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $profession = null;
public function __construct(
string $id,
?string $name = null,
?string $email = null,
?string $surname = null,
string $registrationType = self::REGISTRATION_TYPE_NONE,
bool $emailConfirmed = false
) {
$this->id = $id;
$this->name = $name;
$this->surname = $surname;
$this->email = $email;
$this->registrationType = $registrationType;
$this->emailConfirmed = $emailConfirmed;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getSurname(): ?string
{
return $this->surname;
}
public function setSurname(?string $surname): self
{
$this->surname = $surname;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function isEmailConfirmed(): bool
{
return $this->emailConfirmed;
}
public function setEmailConfirmed(bool $emailConfirmed): self
{
$this->emailConfirmed = $emailConfirmed;
return $this;
}
public function getRegistrationType(): string
{
return $this->registrationType;
}
public function setRegistrationType(string $registrationType): self
{
$this->registrationType = $registrationType;
return $this;
}
public function isSiteRegistered(): bool
{
return $this->registrationType === self::REGISTRATION_TYPE_SITE;
}
public function isGoogleRegistered(): bool
{
return $this->registrationType === self::REGISTRATION_TYPE_GOOGLE;
}
public function isFacebookRegistered(): bool
{
return $this->registrationType === self::REGISTRATION_TYPE_FACEBOOK;
}
public function getProfession(): ?string
{
return $this->profession;
}
public function setProfession(?string $profession): void
{
$this->profession = $profession;
}
}