Completed
Pull Request — dev (#36)
by nonanerz
04:32
created

EmailNotification::sendNotification()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
crap 2
1
<?php
2
3
namespace AppBundle\Notification;
4
5
class EmailNotification
6
{
7
    /**
8
     * @var \Swift_Mailer
9
     */
10
    private $mailer;
11
    /**
12
     * @var \Twig_Environment
13
     */
14
    private $twig;
15
16
    private $from;
17
18
    public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, $from)
19
    {
20
        $this->mailer = $mailer;
21
        $this->twig = $twig;
22
        $this->from = $from;
23
    }
24
25
    public function sendNotification($email)
26
    {
27
        $message = \Swift_Message::newInstance();
28
        $message
29
            ->setSubject('Hello Email')
30
            ->setFrom($this->from)
31
            ->setTo($email)
32
            ->setBody($this->twig->render('AppBundle:Email:email.html.twig'),
33
                'text/html');
34
        $this->mailer->send($message);
35
    }
36
}
37