Sender::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
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