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

UtilitaExtension   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 51
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonDecode() 0 3 1
A getParameter() 0 3 1
A getParametroTabella() 0 3 1
A getLarghezzacolonna() 0 8 2
A __construct() 0 3 1
A getFilters() 0 5 1
A getFunctions() 0 5 1
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