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