src/Entity/User.php line 15
<?phpdeclare(strict_types=1);namespace App\Entity;use App\Enum\Admin\RolesEnum;use App\Repository\UserRepository;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Security\Core\User\UserInterface;#[ORM\Entity(repositoryClass: UserRepository::class)]#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]class User implements UserInterface, PasswordAuthenticatedUserInterface{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 180, unique: true)]private ?string $email = null;#[ORM\Column(length: 255, nullable: true)]private ?string $firstname = null;#[ORM\Column(length: 255, nullable: true)]private ?string $lastname = null;#[ORM\Column]private array $roles = [];#[ORM\Column(type: 'string', nullable: true)]private ?string $password = null;#[ORM\Column(type: 'boolean')]private bool $isVerified = false;#[ORM\Column(type: 'boolean')]private bool $receiveNotifications = false;#[ORM\Column(length: 2)]private string $lang = 'en';public function __construct(){}public function getId(): ?int{return $this->id;}public function getEmail(): ?string{return $this->email;}public function setEmail(string $email): self{$this->email = $email;return $this;}public function getLogin(): ?string{return $this->login;}public function setLogin(string $login): self{$this->login = $login;return $this;}public function getFirstname(): ?string{return $this->firstname;}public function setFirstname(?string $firstname): self{$this->firstname = $firstname;return $this;}public function getLastname(): ?string{return $this->lastname;}public function setLastname(?string $lastname): self{$this->lastname = $lastname;return $this;}/*** A visual identifier that represents this user.** @see UserInterface*/public function getUserIdentifier(): string{return (string)$this->email;}/*** @see UserInterface*/public function getRoles(): array{$roles = $this->roles;// guarantee every user at least has ROLE_USER$roles[] = RolesEnum::ROLE_USER->name;RolesEnum::sortTextRoles($roles);return array_unique($roles);}public function setRoles(array $roles): self{$this->roles = $roles;return $this;}/*** @see PasswordAuthenticatedUserInterface*/public function getPassword(): string{return $this->password;}public function setPassword(?string $password): self{if (!is_null($password)) {$this->password = $password;}return $this;}/*** @see UserInterface*/public function eraseCredentials(): void{// If you store any temporary, sensitive data on the user, clear it here// $this->plainPassword = null;}public function isVerified(): bool{return $this->isVerified;}public function setIsVerified(bool $isVerified): self{$this->isVerified = $isVerified;return $this;}public function getReceiveNotifications(): bool{return $this->receiveNotifications;}public function setReceiveNotifications(bool $receiveNotifications): self{$this->receiveNotifications = $receiveNotifications;return $this;}public function getLang(): string{return $this->lang ?: 'en';}public function setLang(string $lang): self{$this->lang = $lang;return $this;}public function getFullName(): string{return trim(implode(' ', array_filter([$this->getFirstname(),$this->getLastname(),])));}}