src/Core/Model/User.php line 32
<?phpdeclare(strict_types=1);/*** Copyright (c) 2019 TECLA Consulting Group oü.* All rights reserved.** This unpublished material is proprietary to TECLA Consulting Group oü.* All rights reserved. The methods and* techniques described herein are considered trade secrets* and/or confidential. Reproduction or distribution, in whole* or in part, is forbidden except by express written permission* of TECLA Consulting Group oü.** @author Matúš Sýkorjak <matus@tecla.no>* @copyright 2019 TECLA Consulting Group oü*/namespace App\Core\Model;use App\Contact\Model\ContactInterface;use App\Core\Model\Identity\UserIdInterface;use JetBrains\PhpStorm\Pure;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Validator\Constraints as Assert;#[UniqueEntity(fields: 'username',message: 'username.not_unique',ignoreNull: false,)]class User implements UserInterface{protected UserIdInterface $id;protected \DateTimeImmutable $createdAt;protected ?\DateTimeImmutable $updatedAt;#[Assert\NotBlank(message: 'username.blank',)]#[Assert\Email(message: 'username.invalid',)]protected ?string $username;protected ?string $password;protected ?string $legacyPassword;protected ?string $confirmationToken;protected ?string $passwordResetToken;#[Assert\Valid]protected ?ContactInterface $contact;protected ?ContactInterface $invitedBy;#[Assert\NotBlank(message: 'password.blank',)]#[Assert\Length(min: 8,minMessage: 'password.minimum_length',)]protected ?string $plainPassword = null;#[Assert\NotNull(message: 'locale.blank',)]protected ?string $locale;protected ?\DateTimeImmutable $passwordResetTokenUpdatedAt;public function __construct(UserIdInterface $id){$this->id = $id;$this->username = null;$this->password = null;$this->legacyPassword = null;$this->confirmationToken = null;$this->passwordResetToken = null;$this->contact = null;$this->invitedBy = null;$this->locale = null;$this->passwordResetTokenUpdatedAt = null;}public function getId(): UserIdInterface{return $this->id;}public function getCreatedAt(): \DateTimeImmutable{return $this->createdAt;}public function setCreatedAt(\DateTimeImmutable $createdAt): void{$this->createdAt = $createdAt;$this->setUpdatedAt($createdAt);}public function getUpdatedAt(): \DateTimeImmutable{return $this->updatedAt;}public function setUpdatedAt(\DateTimeImmutable $updatedAt): void{$this->updatedAt = $updatedAt;}#[Pure]public function getUsername(): ?string{return $this->getUserIdentifier();}public function setUsername(?string $username): void{$this->username = $username;}public function getUserIdentifier(): string{return $this->username ?? '';}/*** Sets the username used to authenticate the user.*/public function setUserIdentifier(string $userIdentifier): void{$this->username = $userIdentifier;}#[Pure]public function getEmail(): string{return $this->getUserIdentifier();}/*** Sets the e-mail.*/public function setEmail(string $email): void{$this->setUserIdentifier($email);}public function getPassword(): ?string{return $this->password;}/*** Sets the hashed password used to authenticate the user.*/public function setPassword(string $password): void{$this->password = $password;}public function getLegacyPassword(): ?string{return $this->legacyPassword;}public function setLegacyPassword(?string $legacyPassword): void{$this->legacyPassword = $legacyPassword;}/*** Gets the plain password.** @return string*/public function getPlainPassword(): ?string{return $this->plainPassword;}/*** Sets the plain password.*/public function setPlainPassword(string $plainPassword): void{$this->plainPassword = $plainPassword;}/*** Gets the confirmation token.*/public function getConfirmationToken(): ?string{return $this->confirmationToken;}/*** Sets the confirmation token.** @param string $confirmationToken*/public function setConfirmationToken(?string $confirmationToken): void{$this->confirmationToken = $confirmationToken;}/*** Returns the Contact.*/public function getContact(): ?ContactInterface{return $this->contact;}/*** Sets the Contact.*/public function setContact(ContactInterface $contact): void{$this->contact = $contact;$contact->setUser($this);}/*** Returns the Contact what invited user.*/public function getInvitedBy(): ?ContactInterface{return $this->invitedBy;}/*** Sets the Contact what invited user.*/public function setInvitedBy(ContactInterface $invitedBy): void{$this->invitedBy = $invitedBy;}/*** Returns the roles granted to the user.** @return string[] The user roles*/public function getRoles(): array{return ['ROLE_USER'];}/*** Returns the salt that was originally used to encode the password.** @return string|null The salt*/public function getSalt(): ?string{return 'salt';}/*** Removes sensitive data from the user.*/public function eraseCredentials(){$this->plainPassword = null;}public function getLocale(): ?string{return $this->locale;}public function setLocale(string $locale): void{$this->locale = $locale;}public function setPasswordResetToken(?string $passwordResetToken): void{$this->passwordResetToken = $passwordResetToken;if (null === $passwordResetToken) {$this->setPasswordResetTokenUpdatedAt(null);} else {$this->setPasswordResetTokenUpdatedAt(new \DateTimeImmutable());}}public function getPasswordResetToken(): ?string{return $this->passwordResetToken;}public function getPasswordResetTokenUpdatedAt(): ?\DateTimeImmutable{return $this->passwordResetTokenUpdatedAt;}public function setPasswordResetTokenUpdatedAt(?\DateTimeImmutable $passwordResetTokenUpdatedAt): void{$this->passwordResetTokenUpdatedAt = $passwordResetTokenUpdatedAt;}public function __serialize(): array{return ['id' => $this->id,'username' => $this->username,'password' => $this->password,'legacyPassword' => $this->legacyPassword,];}public function __unserialize(array $data): void{$this->id = $data['id'];$this->username = $data['username'];$this->password = $data['password'];$this->legacyPassword = $data['legacyPassword'];}}