Passed
Push — master ( db039c...4d8c20 )
by Dāvis
04:33
created

FlashExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getAlertPublisher() 0 3 1
A getFunctions() 0 16 1
A renderFlashAlerts() 0 3 1
1
<?php
2
3
namespace Sludio\HelperBundle\Script\Twig;
4
5
use Sludio\HelperBundle\Script\Helper\FlashAlertsHelper;
6
7
class FlashExtension extends \Twig_Extension
8
{
9
    use TwigTrait;
10
11
    private $publisher;
12
13
    /**
14
     * @var FlashAlertsHelper
15
     */
16
    private $helper;
17
18
    public function __construct($shortFunctions, $publisher, $helper)
19
    {
20
        $this->shortFunctions = $shortFunctions;
21
        $this->publisher = $publisher;
22
        $this->helper = $helper;
23
    }
24
25
    public function getAlertPublisher()
26
    {
27
        return $this->publisher;
28
    }
29
30
    public function renderFlashAlerts(array $options = [])
31
    {
32
        return $this->helper->renderFlashAlerts($options);
33
    }
34
35
    public function getFunctions()
36
    {
37
        $input = [
38
            'get_alert_publisher' => [
39
                $this,
40
                'getAlertPublisher',
41
                ['is_safe' => ['html']],
42
            ],
43
            'render_flash_alerts' => [
44
                $this,
45
                'renderFlashAlerts',
46
                ['is_safe' => ['html']],
47
            ],
48
        ];
49
50
        return $this->makeArray($input, 'function');
51
    }
52
}
53