| Conditions | 3 |
| Paths | 4 |
| Total Lines | 34 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 24 |
| CRAP Score | 3.004 |
| Changes | 0 | ||
| 1 | <?php |
||
| 43 | 22 | public function sendEmail($tuttoOk, $mail, $vul) |
|
| 44 | { |
||
| 45 | 22 | $soggetto=Config::get('composer-security-check.mailSubjectSuccess'); |
|
| 46 | |||
| 47 | 22 | if (!$tuttoOk) { |
|
| 48 | 10 | $soggetto=Config::get('composer-security-check.mailSubjetcAlarm'); |
|
| 49 | 10 | } |
|
| 50 | |||
| 51 | 22 | $validator = Validator::make(['email' => $mail], [ |
|
| 52 | 22 | 'email' => 'required|email', |
|
| 53 | 22 | ]); |
|
| 54 | 22 | if ($validator->fails()) { |
|
| 55 | $this->command->error('No valid email passed: '.$mail.'. Mail will not be sent.'); |
||
| 56 | return; |
||
| 57 | } |
||
| 58 | 22 | $this->command->line('Send email to <info>'.$mail.'</info>'); |
|
| 59 | |||
| 60 | 22 | Mail::send( |
|
| 61 | 22 | Config::get('composer-security-check.mailViewName'), |
|
| 62 | 22 | ['vul' => $vul], |
|
| 63 | 22 | function ($message) use ($mail, $soggetto) { |
|
| 64 | 22 | $message->from( |
|
| 65 | 22 | Config::get('composer-security-check.mailFrom'), |
|
| 66 | 22 | Config::get('composer-security-check.mailFromName') |
|
| 67 | 22 | ); |
|
| 68 | 22 | $message->to($mail, $mail); |
|
| 69 | 22 | $message->subject($soggetto); |
|
| 70 | 22 | } |
|
| 71 | 22 | ); |
|
| 72 | |||
| 73 | |||
| 74 | 22 | $this->command->line('email sent.'); |
|
| 75 | |||
| 76 | 22 | } |
|
| 77 | } |
||
| 78 |