Passed
Push — master ( 432b63...d5390f )
by Andrea
37:11 queued 18:11
created

UtilitaExtension::getParametroTabella()   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\AbstractExtension
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
    public function getFunctions()
20
    {
21
        return array(
22
            new \Twig_SimpleFunction('json_decode', array($this, 'jsonDecode', 'is_safe' => array('html'))),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFunction has been deprecated: since Twig 2.7, use "Twig\TwigFunction" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

22
            /** @scrutinizer ignore-deprecated */ new \Twig_SimpleFunction('json_decode', array($this, 'jsonDecode', 'is_safe' => array('html'))),
Loading history...
23
            new \Twig_SimpleFunction('parameter', array($this, 'getParameter', 'is_safe' => array('html'))),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFunction has been deprecated: since Twig 2.7, use "Twig\TwigFunction" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

23
            /** @scrutinizer ignore-deprecated */ new \Twig_SimpleFunction('parameter', array($this, 'getParameter', 'is_safe' => array('html'))),
Loading history...
24
        );
25
    }
26
27
    public function getFilters()
28
    {
29
        return array(
30
            new \Twig_SimpleFilter('getparametrotabella', array($this, 'getParametroTabella')),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFilter has been deprecated: since Twig 2.7, use "Twig\TwigFilter" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

30
            /** @scrutinizer ignore-deprecated */ new \Twig_SimpleFilter('getparametrotabella', array($this, 'getParametroTabella')),
Loading history...
31
            new \Twig_SimpleFilter('larghezzacolonna', array($this, 'getLarghezzacolonna')),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFilter has been deprecated: since Twig 2.7, use "Twig\TwigFilter" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

31
            /** @scrutinizer ignore-deprecated */ new \Twig_SimpleFilter('larghezzacolonna', array($this, 'getLarghezzacolonna')),
Loading history...
32
        );
33
    }
34
35 7
    public function jsonDecode($string)
36
    {
37 7
        return json_decode($string);
38
    }
39
40 1
    public function getParameter($parameter)
41
    {
42 1
        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