LaravelMailer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 54.55%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 46
ccs 6
cts 11
cp 0.5455
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 14 3
1
<?php
2
3
namespace CodeZero\Mailer;
4
5
use Illuminate\Contracts\Mail\MailQueue;
6
7
class LaravelMailer implements Mailer
8
{
9
    /**
10
     * Laravel Mail Queue
11
     *
12
     * @var MailQueue
13
     */
14
    private $mail;
15
16
    /**
17
     * Create a new instance of LaravelMailer.
18
     *
19
     * @param MailQueue $mail
20
     */
21 2
    public function __construct(MailQueue $mail)
22
    {
23 2
        $this->mail = $mail;
24 2
    }
25
26
    /**
27
     * Send an e-mail.
28
     *
29
     * @param string $toEmail
30
     * @param string $toName
31
     * @param string $subject
32
     * @param string $view
33
     * @param array $data
34
     * @param callable $options
35
     *
36
     * @return void
37
     */
38
    public function send($toEmail, $toName, $subject, $view, array $data = array(), $options = null)
39
    {
40 1
        $this->mail->queue($view, $data, function ($message) use ($toEmail, $toName, $subject, $options) {
41
42
            $message->to($toEmail, $toName)
43
                    ->subject($subject);
44
45
            // Allow the caller to run additional functions
46
            // on the $msg SwiftMailer object (cc, bcc, attach, ...)
47
            if ($options && is_callable($options)) {
48
                call_user_func($options, $message);
49
            }
50 1
        });
51 1
    }
52
}
53