Mailer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 77
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 77
ccs 0
cts 28
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 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
     * @var string
25
     */
26
    private $from;
27
28
    /**
29
     * @var string
30
     */
31
    private $to;
32
33
    /**
34
     * @var string
35
     */
36
    private $subject;
37
38
    /**
39
     * @var string
40
     */
41
    private $template;
42
43
    /**
44
     * @param \Swift_Mailer       $mailer
45
     * @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...
46
     * @param EngineInterface     $templating
47
     * @param string              $from
48
     * @param string              $to
49
     * @param string              $subject
50
     * @param string              $template
51
     */
52
    public function __construct(
53
        \Swift_Mailer $mailer,
54
        EngineInterface $templating,
55
        $from,
56
        $to,
57
        $subject,
58
        $template
59
    ){
60
     $this->mailer = $mailer;
61
     $this->templating = $templating;
62
     $this->from = $from;
63
     $this->to = $to;
64
     $this->subject = $subject;
65
     $this->template = $template;
66
    }
67
68
    /**
69
     * @param string $channelName
70
     *
71
     * @return mixed
72
     */
73
    public function process($channelName)
74
    {
75
        $body = $this->templating->render(
76
            $this->template,
77
            ['channel' => $channelName]
78
        );
79
80
        $message = \Swift_Message::newInstance();
81
        $message->setSubject($this->subject)
82
            ->setFrom($this->from)
83
            ->setTo($this->to)
84
            ->setBody($body);
85
        $this->mailer->send($message);
86
    }
87
}
88