| Conditions | 3 | 
| Paths | 4 | 
| Total Lines | 24 | 
| Code Lines | 15 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 42 | public function sendEmail(User $user): void | ||
| 43 |     { | ||
| 44 | $tokenizer = new Tokenizer(); | ||
| 45 |         if (!$tokenizer->validate($user->email_confirm_token)) { | ||
| 46 | $user->setEmailConfirmToken($tokenizer->generate()); | ||
| 47 | $user->updateAttributes([ | ||
| 48 | 'email_confirm_token' => $user->email_confirm_token, | ||
| 49 | 'date_confirm' => $user->date_confirm, | ||
| 50 | ]); | ||
| 51 | } | ||
| 52 | |||
| 53 | $sent = Yii::$app->notify->sendMessage( | ||
| 54 | $user->email, | ||
| 55 |             Yii::t('app', 'Activate Your Account'), | ||
| 56 | 'emailConfirmToken', | ||
| 57 | ['user' => $user] | ||
| 58 | ); | ||
| 59 | |||
| 60 |         if (!$sent) { | ||
| 61 | throw new UserException( | ||
| 62 |                 Yii::t('app.msg', 'An error occurred while sending a message to activate account') | ||
| 63 | ); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | } | ||
| 67 |