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