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

EmailNotification   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 32
ccs 14
cts 14
cp 1
rs 10
c 2
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A sendNotification() 0 11 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