Completed
Pull Request — master (#30)
by
unknown
06:09
created

EmailNotification::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

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