Completed
Push — master ( 3afd02...a4590b )
by Vojta
04:54
created

ReservationMailer::getTemplateIdent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 12
loc 12
ccs 6
cts 7
cp 0.8571
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
crap 2.0116
1
<?php namespace VojtaSvoboda\Reservations\Mailers;
2
3
use App;
4
use Mail;
5
use Request;
6
use VojtaSvoboda\Reservations\Models\Reservation;
7
8
class ReservationMailer extends BaseMailer
9
{
10
    /**
11
     * Send reservation confirmation mail.
12
     *
13
     * @param Reservation $reservation
14
     * @param int $reservationsCount
15
     */
16
    public function send(Reservation $reservation, $reservationsCount = 0)
17
    {
18
        // init
19
        $locale = App::getLocale();
20 6
        $appUrl = App::make('url')->to('/');
21
        $recipients = $this->initRecipients();
22 6
        $recipients['email'] = $reservation->email;
23 6
        $recipients['name'] = trim($reservation->name . ' ' . $reservation->lastname);
24
25
        $template = $this->getTemplateIdent('reservation');
26
27
        $templateParameters = [
28
            'site' => $appUrl,
29
            'reservation' => $reservation,
30
            'locale' => $locale,
31
            'reservationsCount' => $reservationsCount,
32
        ];
33
34
        if (App::environment() === 'testing') {
35
            return;
36
        }
37
38 View Code Duplication
        Mail::send($template, $templateParameters, function($message) use ($recipients)
1 ignored issue
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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