src/Entity/User.php line 19
<?phpnamespace App\Entity;use App\Entity\Trait\DateTrait;use App\Entity\Trait\IdTrait;use App\Repository\UserRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;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\Table(name: '`user`')]#[ORM\Entity(repositoryClass: UserRepository::class)]#[ORM\HasLifecycleCallbacks]#[UniqueEntity(fields: ['email'], message: 'Cette adresse email est déjà utilisée')]class User implements UserInterface, PasswordAuthenticatedUserInterface{use IdTrait;use DateTrait;const ROLE_DEFAULT = 'ROLE_USER';#[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(length: 255, nullable: true)]private ?string $phoneNumber = null;#[ORM\Column]private array $roles = [];/*** @var string The hashed password*/#[ORM\Column]private ?string $password = null;#[ORM\Column(options: ['default' => false])]private ?bool $isVerified = null;#[ORM\OneToMany(mappedBy: 'owner', targetEntity: Image::class)]private Collection $ownedImages;public function __construct(){$this->isVerified = false;$this->ownedImages = new ArrayCollection();}/*** A visual identifier that represents this user.** @see UserInterface*/public function getUserIdentifier(): string{return (string) $this->email;}public function getEmail(): ?string{return $this->email;}public function setEmail(?string $email): self{$this->email = $email;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;}public function getFullName(): ?string{$tab = [];if ($this->lastName !== null) {$tab[] = $this->firstName;}if ($this->lastName !== null) {$tab[] = $this->lastName;}if (count($tab)) {return implode(' ', $tab);}return null;}public function getPhoneNumber(): ?string{return $this->phoneNumber;}public function setPhoneNumber(?string $phoneNumber): self{$this->phoneNumber = $phoneNumber;return $this;}/*** @see UserInterface*/public function getRoles(): array{$roles = $this->roles;// guarantee every user at least has ROLE_USER$roles[] = self::ROLE_DEFAULT;return array_unique($roles);}public function setRoles(array $roles): self{$this->roles = $roles;return $this;}public function addRole(string $role): self{$this->roles[] = $role;$this->roles = array_unique($this->roles);return $this;}/*** @see PasswordAuthenticatedUserInterface*/public function getPassword(): string{return $this->password;}public function setPassword(?string $password): self{$this->password = $password;return $this;}/*** @see UserInterface*/public function eraseCredentials(){// 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;}/*** @return Collection<int, Image>*/public function getOwnedImages(): Collection{return $this->ownedImages;}public function addOwnedImage(Image $ownedImage): self{if (!$this->ownedImages->contains($ownedImage)) {$this->ownedImages->add($ownedImage);$ownedImage->setOwner($this);}return $this;}public function removeOwnedImage(Image $ownedImage): self{if ($this->ownedImages->removeElement($ownedImage)) {// set the owning side to null (unless already changed)if ($ownedImage->getOwner() === $this) {$ownedImage->setOwner(null);}}return $this;}}