1 | <?php |
||
15 | trait TokenTrait |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * inject a token in the user model itself. |
||
20 | * if no token provided generate token first. |
||
21 | * |
||
22 | * @param null $token |
||
23 | * |
||
24 | * @return $this |
||
25 | */ |
||
26 | public function injectToken($token) |
||
33 | |||
34 | /** |
||
35 | * When calling this function, the token will be added on the model. |
||
36 | * |
||
37 | * @return $this |
||
38 | */ |
||
39 | public function withToken() |
||
43 | } |
||
44 |
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: