Guest User

Untitled

a guest
Aug 13th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * @property int $id {primary}
  5.  * @property string $username
  6.  * @property-read string $passwordHash
  7.  * @property-write string $password {virtual}
  8.  * @property-read DateTimeImmutable $createdAt {virtual}
  9.  * @property-read DateTimeImmutable $updatedAt {virtual}
  10.  *
  11.  * @property AuthorEntity $author {1:1 AuthorEntity::$user}
  12.  */
  13. class UserEntity extends Entity
  14. {
  15.     public static function construct(string $username, string $password): self
  16.     {
  17.         $obj = new self();
  18.         $obj->username = $username;
  19.         $obj->password = $password;
  20.  
  21.         return $obj;
  22.     }
  23.  
  24.     public function setterPassword(string $password)
  25.     {
  26.         $this->setReadOnlyValue('passwordHash', Authenticator::generatePasswordHash($password));
  27.     }
  28. }
Add Comment
Please, Sign In to add comment