Passed
Push — master ( a8ebbd...a6772f )
by Andrea
18:44 queued 12s
created

HeaderTabellaExtension::getFunctions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Cdf\BiCoreBundle\Twig\Extension;
4
5
class HeaderTabellaExtension 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

5
class HeaderTabellaExtension extends /** @scrutinizer ignore-deprecated */ \Twig_Extension
Loading history...
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10
    public function getFunctions()
11
    {
12
        return array(
13
            new \Twig_SimpleFunction('sort_class', array($this, 'sortClass', '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

13
            /** @scrutinizer ignore-deprecated */ new \Twig_SimpleFunction('sort_class', array($this, 'sortClass', 'is_safe' => array('html'))),
Loading history...
14
        );
15
    }
16
17 6
    public function sortClass($colonneordinamento, $modellocampo)
18
    {
19 6
        if (true === $modellocampo['association'] || true === $modellocampo['campoextra']) {
20 3
            $sorttype = '';
21
        } else {
22 6
            $cursort = json_decode($colonneordinamento, true);
23 6
            if (array_key_exists($modellocampo['nomecampo'], $cursort)) {
24 6
                if ('ASC' == $cursort[$modellocampo['nomecampo']]) {
25 1
                    $sorttype = 'sorting_asc';
26
                } else {
27 6
                    $sorttype = 'sorting_desc';
28
                }
29
            } else {
30 6
                $sorttype = 'sorting';
31
            }
32
        }
33
34 6
        return $sorttype;
35
    }
36
}
37