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

EmailNotification   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 32
ccs 0
cts 17
cp 0
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
    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