| Conditions | 2 |
| Paths | 2 |
| Total Lines | 23 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 32 | public function run(User $user) |
||
| 33 | { |
||
| 34 | // check if email exist on the user |
||
| 35 | if (!$user->email) { |
||
|
|
|||
| 36 | throw new UserEmailNotFoundException; |
||
| 37 | } |
||
| 38 | |||
| 39 | // generate random unique token |
||
| 40 | $confirmationCode = sha1(time() . $user->id); |
||
| 41 | |||
| 42 | // 3. set token next to user id in the memory (redis) |
||
| 43 | Cache::put('user:email-confirmation-code:' . $user->id, $confirmationCode, |
||
| 44 | self::CONFIRMATION_CODE_VALIDATE_TIME); |
||
| 45 | |||
| 46 | // set user status not confirmed (in case the user is updating his email) |
||
| 47 | $user->confirmed = false; |
||
| 48 | $user->save(); |
||
| 49 | |||
| 50 | // build the url email confirmation URL with the confirmation code and user id |
||
| 51 | $confirmationUrl = URL::to('/') . '/users/' . $user->id . '/email/confirmation/' . $confirmationCode; |
||
| 52 | |||
| 53 | return $confirmationUrl; |
||
| 54 | } |
||
| 55 | } |
||
| 56 |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.