NotifierExtension::getErrbitNotifier()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 2
1
<?php
2
3
namespace SumoCoders\FrameworkErrorBundle\Twig;
4
5
/**
6
 * NotifierExtension
7
 */
8
class NotifierExtension extends \Twig_Extension
9
{
10
    /**
11
     * @var \Twig_Environment
12
     */
13
    protected $twig;
14
15
    /**
16
     * @var string
17
     */
18
    protected $host;
19
20
    /**
21
     * @var string
22
     */
23
    protected $apiKey;
24
25
    /**
26
     * Class constructor
27
     *
28
     * @param \Twig_Environment $twig
29
     * @param string            $host
30
     * @param string            $apiKey
31
     */
32 4
    public function __construct(\Twig_Environment $twig, $host, $apiKey)
33
    {
34 4
        $this->twig = $twig;
35 4
        $this->host = $host;
36 4
        $this->apiKey = $apiKey;
37 4
    }
38
39
    /**
40
     * {@inheritDoc}
41
     */
42 2
    public function getFunctions()
43
    {
44
        return array(
45 2
            new \Twig_SimpleFunction(
46 2
                'errbit_notifier',
47 2
                array($this, 'getErrbitNotifier'),
48
                array(
49 2
                    'is_safe' => array('html'),
50
                )
51
            )
52
        );
53
    }
54
55
    /**
56
     * Returns the HTML that will be inserted by rendering the template
57
     *
58
     * @return string
59
     */
60
    public function getErrbitNotifier()
61
    {
62
        return $this->twig->render(
63
            'SumoCodersFrameworkErrorBundle:Extension:notifier.html.twig',
64
            array(
65
                'host' => $this->host,
66
                'api_key' => $this->apiKey,
67
            )
68
        );
69
    }
70
71
    /**
72
     * @return string
73
     */
74 3
    public function getName()
75
    {
76 3
        return 'errbit_notifier_extension';
77
    }
78
}
79