Sender   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 2
c 3
b 0
f 2
lcom 1
cbo 2
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A send() 0 9 1
1
<?php
2
3
namespace DoS\UserBundle\Confirmation\OTP;
4
5
use DoS\UserBundle\Confirmation\SenderInterface;
6
use SmsSender\SmsSenderInterface;
7
8
class Sender implements SenderInterface
9
{
10
    /**
11
     * @var SmsSenderInterface
12
     */
13
    protected $sender;
14
15
    /**
16
     * @var \Twig_Environment
17
     */
18
    protected $twig;
19
20
    public function __construct(SmsSenderInterface $sender, \Twig_Environment $twig)
21
    {
22
        $this->sender = $sender;
23
        $this->twig = $twig;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function send($template, array $recipients, array $data = array())
30
    {
31
        $data = $this->twig->mergeGlobals($data);
32
        $template = $this->twig->loadTemplate($template);
33
        $content = $template->renderBlock('content', $data);
34
        $originator = $template->renderBlock('originator', $data);
35
36
        $this->sender->send($recipients[0], $content, $originator);
37
    }
38
}
39