Completed
Push — master ( aa9f24...ead1f2 )
by Andrea
20:48 queued 17:21
created

UtilitaExtension::getParameter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Cdf\BiCoreBundle\Twig\Extension;
4
5
use Cdf\BiCoreBundle\Utils\Tabella\ParametriTabella;
6
7
class UtilitaExtension extends \Twig_Extension
8
{
9
    private $container;
10
11 26
    public function __construct($container)
12
    {
13 26
        $this->container = $container;
14 26
    }
15
16
    /**
17
     * {@inheritdoc}
18
     */
19 1
    public function getFunctions()
20
    {
21
        return array(
22 1
            new \Twig_SimpleFunction('json_decode', array($this, 'jsonDecode', 'is_safe' => array('html'))),
23 1
            new \Twig_SimpleFunction('parameter', array($this, 'getParameter', 'is_safe' => array('html'))),
24
        );
25
    }
26
27 1
    public function getFilters()
28
    {
29
        return array(
30 1
            new \Twig_SimpleFilter('getparametrotabella', array($this, 'getParametroTabella')),
31 1
            new \Twig_SimpleFilter('larghezzacolonna', array($this, 'getLarghezzacolonna')),
32
        );
33
    }
34
35 7
    public function jsonDecode($string)
36
    {
37 7
        return json_decode($string);
38
    }
39
40 12
    public function getParameter($parameter)
41
    {
42 12
        return $this->container->getParameter($parameter);
43
    }
44
45 11
    public function getParametroTabella($parametro)
46
    {
47 11
        return ParametriTabella::getParameter($parametro);
48
    }
49
50 6
    public function getLarghezzacolonna($larghezza)
51
    {
52 6
        $class = 'biw-5';
53 6
        if ($larghezza) {
54 6
            $class = 'biw-'.$larghezza;
55
        }
56
57 6
        return $class;
58
    }
59
}
60