Passed
Push — master ( 5a5431...a8ebbd )
by Andrea
28:38 queued 18:22
created

UtilitaExtension::getLarghezzacolonna()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
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
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Extension has been deprecated: since Twig 2.7, use "Twig\Extension\AbstractExtension" instead ( Ignorable by Annotation )

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

7
class UtilitaExtension extends /** @scrutinizer ignore-deprecated */ \Twig_Extension
Loading history...
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'))),
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 1
            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 1
    public function getFilters()
28
    {
29
        return array(
30 1
            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 1
            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 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