Passed
Push — master ( 09ce70...3c2452 )
by Andrea
32:18 queued 16s
created

HeaderTabellaExtension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 30
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sortClass() 0 18 5
A getFunctions() 0 4 1
1
<?php
2
3
namespace Cdf\BiCoreBundle\Twig\Extension;
4
5
use Twig\Extension\AbstractExtension;
6
use Twig\TwigFunction;
7
8
class HeaderTabellaExtension extends AbstractExtension
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 1
    public function getFunctions()
14
    {
15
        return array(
16 1
            new TwigFunction('sort_class', array($this, 'sortClass', 'is_safe' => array('html'))),
17
        );
18
    }
19
20 7
    public function sortClass($colonneordinamento, $modellocampo)
21
    {
22 7
        if (true === $modellocampo['association'] || true === $modellocampo['campoextra']) {
23 4
            $sorttype = '';
24
        } else {
25 7
            $cursort = json_decode($colonneordinamento, true);
26 7
            if (array_key_exists($modellocampo['nomecampo'], $cursort)) {
27 6
                if ('ASC' == $cursort[$modellocampo['nomecampo']]) {
28 1
                    $sorttype = 'sorting_asc';
29
                } else {
30 6
                    $sorttype = 'sorting_desc';
31
                }
32
            } else {
33 7
                $sorttype = 'sorting';
34
            }
35
        }
36
37 7
        return $sorttype;
38
    }
39
}
40