Completed
Pull Request — master (#41)
by guillaume
03:05
created

Mailer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 70
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A process() 0 14 1
1
<?php
2
3
namespace Itkg\DelayEventBundle\Notifier;
4
5
use Symfony\Component\Templating\EngineInterface;
6
use Symfony\Component\Translation\TranslatorInterface;
7
8
/**
9
 * Class Mailer
10
 */
11
class Mailer implements NotifierInterface
12
{
13
    /**
14
     * @var \Swift_Mailer
15
     */
16
    private $mailer;
17
18
    /**
19
     * @var EngineInterface
20
     */
21
    private $templating;
22
23
24
    /**
25
     * @var string
26
     */
27
    private $from;
28
29
    /**
30
     * @var string
31
     */
32
    private $to;
33
34
    /**
35
     * @var string
36
     */
37
    private $subject;
38
39
    /**
40
     * @param \Swift_Mailer       $mailer
41
     * @param TranslatorInterface $translator
0 ignored issues
show
Bug introduced by
There is no parameter named $translator. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
42
     * @param EngineInterface     $templating
43
     * @param string              $from
44
     * @param string              $to
45
     * @param string              $subject
46
     */
47
    public function __construct(
48
        \Swift_Mailer $mailer,
49
        EngineInterface $templating,
50
        $from,
51
        $to,
52
        $subject
53
    ){
54
     $this->mailer = $mailer;
55
     $this->templating = $templating;
56
     $this->from = $from;
57
     $this->to = $to;
58
     $this->subject = $subject;
59
    }
60
61
    /**
62
     * @param string $channelName
63
     *
64
     * @return mixed
65
     */
66
    public function process($channelName)
67
    {
68
        $body = $this->templating->render(
69
            'ItkgDelayEventBundle:Channel:email.html.twig',
70
            ['channel' => $channelName]
71
        );
72
73
        $message = \Swift_Message::newInstance();
74
        $message->setSubject($this->subject)
75
            ->setFrom($this->from)
76
            ->setTo($this->to)
77
            ->setBody($body);
78
        $this->mailer->send($message);
79
    }
80
}
81