MailerAwareTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 38
rs 10
ccs 0
cts 11
cp 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setMailer() 0 3 1
A initMailer() 0 3 1
A newMailer() 0 3 1
A getMailer() 0 7 2
1
<?php
2
3
namespace Nip\Mail\Traits;
4
5
use Symfony\Component\Mailer\Mailer;
6
7
/**
8
 * Class MailerAwareTrait.
9
 */
10
trait MailerAwareTrait
11
{
12
    /**
13
     * @var Mailer|null
14
     */
15
    protected $mailer = null;
16
17
    /**
18
     * @return Mailer|null
19
     */
20
    public function getMailer()
21
    {
22
        if (null === $this->mailer) {
23
            $this->initMailer();
24
        }
25
26
        return $this->mailer;
27
    }
28
29
    /**
30
     * @param Mailer $mailer
31
     */
32
    public function setMailer($mailer)
33
    {
34
        $this->mailer = $mailer;
35
    }
36
37
    protected function initMailer()
38
    {
39
        $this->setMailer($this->newMailer());
40
    }
41
42
    /**
43
     * @return Mailer
44
     */
45
    protected function newMailer()
46
    {
47
        return app('mailer');
48
    }
49
}
50