| 1 | <?php |
||
| 10 | class UserVO implements JsonSerializable |
||
| 11 | { |
||
| 12 | |||
| 13 | const PROPERTY_AVATAR = 'avatar'; |
||
| 14 | const PROPERTY_EMAIL = 'email'; |
||
| 15 | |||
| 16 | const ROLE_ADMIN = 'admin'; |
||
| 17 | const ROLE_USER = 'user'; |
||
| 18 | |||
| 19 | const AVATAR_1 = 'avatar1.png'; |
||
| 20 | const AVATAR_2 = 'avatar2.png'; |
||
| 21 | const AVATAR_3 = 'avatar3.png'; |
||
| 22 | const AVATAR_4 = 'avatar4.png'; |
||
| 23 | const AVATAR_5 = 'avatar5.png'; |
||
| 24 | |||
| 25 | const ROLES = [ |
||
| 26 | self::ROLE_ADMIN, |
||
| 27 | self::ROLE_USER |
||
| 28 | ]; |
||
| 29 | |||
| 30 | const AVATARS = [ |
||
| 31 | self::AVATAR_1, |
||
| 32 | self::AVATAR_2, |
||
| 33 | self::AVATAR_3, |
||
| 34 | self::AVATAR_4, |
||
| 35 | self::AVATAR_5, |
||
| 36 | ]; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var integer |
||
| 40 | */ |
||
| 41 | public $id; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var string |
||
| 45 | */ |
||
| 46 | public $username; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var string |
||
| 50 | */ |
||
| 51 | public $password_hash; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var string |
||
| 55 | */ |
||
| 56 | public $one_time_secret; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var string |
||
| 60 | */ |
||
| 61 | public $password; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var string |
||
| 65 | */ |
||
| 66 | public $email; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @var string[] |
||
| 70 | */ |
||
| 71 | public $roles = []; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var string |
||
| 75 | */ |
||
| 76 | public $avatar; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @param string $role |
||
| 80 | * @return boolean |
||
| 81 | */ |
||
| 82 | 1 | public function hasRole($role) |
|
| 83 | { |
||
| 84 | 1 | return in_array($role, $this->roles); |
|
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @return string[] |
||
| 89 | */ |
||
| 90 | 1 | public function getRoles() |
|
| 91 | { |
||
| 92 | 1 | return $this->roles; |
|
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * {@inheritdoc} |
||
| 97 | */ |
||
| 98 | 1 | public function getPassword() |
|
| 99 | { |
||
| 100 | 1 | return $this->password_hash; |
|
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * {@inheritdoc} |
||
| 105 | */ |
||
| 106 | 1 | public function getSalt() |
|
| 107 | { |
||
| 108 | 1 | return $this->username; |
|
| 109 | } |
||
| 110 | |||
| 111 | /** |
||
| 112 | * {@inheritdoc} |
||
| 113 | */ |
||
| 114 | 1 | public function getUsername() |
|
| 118 | |||
| 119 | /** |
||
| 120 | * @return array |
||
| 121 | */ |
||
| 122 | 1 | public function jsonSerialize() |
|
| 126 | |||
| 127 | /** |
||
| 128 | * @return array |
||
| 129 | */ |
||
| 130 | 1 | public function toArray() |
|
| 140 | } |
||
| 141 |