| Conditions | 4 |
| Paths | 2 |
| Total Lines | 31 |
| Code Lines | 18 |
| Lines | 8 |
| Ratio | 25.81 % |
| Tests | 13 |
| CRAP Score | 4.5039 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace VojtaSvoboda\Reservations\Mailers; |
||
| 16 | 5 | public function send(Reservation $reservation, $reservationsCount = 0) |
|
| 17 | { |
||
| 18 | // init |
||
| 19 | 5 | $locale = App::getLocale(); |
|
| 20 | 5 | $appUrl = App::make('url')->to('/'); |
|
| 21 | 5 | $recipients = $this->initRecipients(); |
|
| 22 | 5 | $recipients['email'] = $reservation->email; |
|
| 23 | 5 | $recipients['name'] = trim($reservation->name . ' ' . $reservation->lastname); |
|
| 24 | |||
| 25 | 5 | $template = $this->getTemplateIdent('reservation'); |
|
| 26 | |||
| 27 | $templateParameters = [ |
||
| 28 | 5 | 'site' => $appUrl, |
|
| 29 | 5 | 'reservation' => $reservation, |
|
| 30 | 5 | 'locale' => $locale, |
|
| 31 | 5 | 'reservationsCount' => $reservationsCount, |
|
| 32 | ]; |
||
| 33 | |||
| 34 | 5 | if (App::environment() === 'testing') { |
|
| 35 | 5 | return; |
|
| 36 | } |
||
| 37 | |||
| 38 | View Code Duplication | Mail::send($template, $templateParameters, function($message) use ($recipients) |
|
| 39 | { |
||
| 40 | $message->to($recipients['email'], $recipients['name']); |
||
| 41 | |||
| 42 | if (!empty($recipients['bcc_email']) && !empty($recipients['bcc_name'])) { |
||
| 43 | $message->bcc($recipients['bcc_email'], $recipients['bcc_name']); |
||
| 44 | } |
||
| 45 | }); |
||
| 46 | } |
||
| 47 | } |
||
| 48 |