1 | <?php |
||
14 | trait UserTrait |
||
15 | { |
||
16 | /** |
||
17 | * @var string |
||
18 | * |
||
19 | * @ORM\Column(type="string", length=255, nullable=false, unique=true) |
||
20 | * |
||
21 | * @Assert\NotBlank |
||
22 | * @Assert\Email |
||
23 | */ |
||
24 | private $email; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | * |
||
29 | * @ORM\Column(name="password", type="string", length=100, nullable=false) |
||
30 | */ |
||
31 | private $password; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | private $plainPassword; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | * |
||
41 | * @ORM\Column(type="string", length=255, nullable=true) |
||
42 | */ |
||
43 | protected $firstName; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | * |
||
48 | * @ORM\Column(type="string", length=255, nullable=true) |
||
49 | */ |
||
50 | protected $lastName; |
||
51 | |||
52 | /** |
||
53 | * @var DateTime |
||
54 | * |
||
55 | * @ORM\Column(type="datetime", nullable=true) |
||
56 | */ |
||
57 | private $passwordRequestedAt; |
||
58 | |||
59 | /** |
||
60 | * @var string |
||
61 | * |
||
62 | * @ORM\Column(type="string", length=100, nullable=true) |
||
63 | */ |
||
64 | private $passwordRequestToken; |
||
65 | |||
66 | /** |
||
67 | * @var array |
||
68 | * |
||
69 | * @ORM\Column(type="json_array") |
||
70 | */ |
||
71 | private $roles; |
||
72 | |||
73 | /** |
||
74 | * @return string |
||
75 | */ |
||
76 | public function __toString() |
||
84 | |||
85 | /** |
||
86 | * On list we want to be able to sort by Lastname |
||
87 | * @return string |
||
88 | */ |
||
89 | public function getListDisplay() |
||
97 | |||
98 | /** |
||
99 | * @return int |
||
100 | */ |
||
101 | public function getId() |
||
105 | |||
106 | /** |
||
107 | * @inheritdoc |
||
108 | */ |
||
109 | public function getUsername() |
||
113 | |||
114 | /** |
||
115 | * @inheritdoc |
||
116 | */ |
||
117 | public function getEmail() |
||
121 | |||
122 | /** |
||
123 | * @param string $email |
||
124 | * |
||
125 | * @return $this |
||
126 | */ |
||
127 | public function setEmail($email) |
||
133 | |||
134 | /** |
||
135 | * @inheritdoc |
||
136 | */ |
||
137 | public function getPassword() |
||
141 | |||
142 | /** |
||
143 | * @param string $password |
||
144 | * |
||
145 | * @return $this |
||
146 | */ |
||
147 | public function setPassword($password) |
||
153 | |||
154 | /** |
||
155 | * @inheritdoc |
||
156 | */ |
||
157 | public function getSalt() |
||
161 | |||
162 | /** |
||
163 | * @return string |
||
164 | */ |
||
165 | public function getPlainPassword() |
||
169 | |||
170 | /** |
||
171 | * @param string $plainPassword |
||
172 | * |
||
173 | * @return $this |
||
174 | */ |
||
175 | public function setPlainPassword($plainPassword) |
||
181 | |||
182 | /** |
||
183 | * @inheritdoc |
||
184 | */ |
||
185 | public function eraseCredentials() |
||
191 | |||
192 | /** |
||
193 | * @param int $ttl |
||
194 | * |
||
195 | * @return bool |
||
196 | */ |
||
197 | public function isPasswordRequestNonExpired($ttl) |
||
201 | |||
202 | /** |
||
203 | * @return DateTime |
||
204 | */ |
||
205 | public function getPasswordRequestedAt() |
||
209 | |||
210 | /** |
||
211 | * @param DateTime $passwordRequestedAt |
||
212 | * |
||
213 | * @return $this |
||
214 | */ |
||
215 | public function setPasswordRequestedAt($passwordRequestedAt) |
||
221 | |||
222 | /** |
||
223 | * @return string |
||
224 | */ |
||
225 | public function getPasswordRequestToken() |
||
229 | |||
230 | /** |
||
231 | * @param string $passwordRequestToken |
||
232 | * |
||
233 | * @return $this |
||
234 | */ |
||
235 | public function setPasswordRequestToken($passwordRequestToken) |
||
241 | |||
242 | /** |
||
243 | * @inheritdoc |
||
244 | */ |
||
245 | public function getRoles() |
||
249 | |||
250 | /** |
||
251 | * @param array $roles |
||
252 | * |
||
253 | * @return $this |
||
254 | */ |
||
255 | public function setRoles(array $roles = []) |
||
261 | |||
262 | /** |
||
263 | * @return string |
||
264 | */ |
||
265 | public function getFirstName() |
||
269 | |||
270 | /** |
||
271 | * @param string $firstName |
||
272 | * |
||
273 | * @return $this |
||
274 | */ |
||
275 | public function setFirstName($firstName) |
||
281 | |||
282 | /** |
||
283 | * @return string |
||
284 | */ |
||
285 | public function getLastName() |
||
289 | |||
290 | /** |
||
291 | * @param string $lastName |
||
292 | * |
||
293 | * @return $this |
||
294 | */ |
||
295 | public function setLastName($lastName) |
||
301 | |||
302 | /** |
||
303 | * @return string |
||
304 | */ |
||
305 | public function getFullName() |
||
309 | |||
310 | /** |
||
311 | * @return string |
||
312 | */ |
||
313 | public function getListFullName() |
||
317 | |||
318 | /** |
||
319 | * @return string |
||
320 | */ |
||
321 | public function getFullNameAndEmail() |
||
329 | |||
330 | /** |
||
331 | * @see \Serializable::serialize() |
||
332 | */ |
||
333 | public function serialize() |
||
341 | |||
342 | /** |
||
343 | * @see \Serializable::unserialize() |
||
344 | */ |
||
345 | public function unserialize($serialized) |
||
355 | } |
||
356 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: