Completed
Pull Request — master (#30)
by
unknown
05:03
created

EmailNotification::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
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, $title = 'Hello!', $content = ' ')
26
    {
27
        $message = new \Swift_Message();
28
        $message
29
            ->setSubject('Hello Email')
30
            ->setFrom($this->from)
31
            ->setTo($email)
32
            ->setBody($this->twig->render('AppBundle:Email:email.html.twig', [
33
                'title' => $title, 'content' => $content, ]), 'text/html');
34
        $this->mailer->send($message);
35
    }
36
}
37