Completed
Push — master ( 2ff726...1b8ace )
by Andrea
09:31
created

GrigliaInfoCampiUtils   A

Complexity

Total Complexity 31

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 49.21%

Importance

Changes 0
Metric Value
wmc 31
lcom 1
cbo 2
dl 0
loc 104
ccs 31
cts 63
cp 0.4921
rs 9.8
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getEtichettaDescrizioneColonna() 0 6 2
A getEtichettaNomeColonna() 0 4 1
A getWidthCampo() 0 14 4
B getIndiceModelloSelect() 0 10 5
B getIndiceModello() 0 10 5
A setModelliColonne() 0 10 3
A setNomiColonne() 0 8 3
A getOrdineColonne() 0 15 4
A getSingoloAliasNormalizzato() 0 6 2
A setOrdineColonne() 0 9 2
1
<?php
2
3
namespace Fi\CoreBundle\DependencyInjection;
4
5
class GrigliaInfoCampiUtils
6
{
7 13
    public static function getEtichettaDescrizioneColonna(&$singoloalias, $chiave)
8
    {
9 13
        $array = array('str' => $chiave, 'primamaiuscola' => true);
10
11 13
        return isset($singoloalias['descrizione']) ? $singoloalias['descrizione'] : GrigliaUtils::toCamelCase($array);
12
    }
13
14
    public static function getEtichettaNomeColonna(&$etichetteutente, $chiave)
15
    {
16
        return GrigliaUtils::toCamelCase(array('str' => trim($etichetteutente[$chiave]), 'primamaiuscola' => true));
17
    }
18
19 8
    public static function getWidthCampo(&$colonna, &$chiave, $singoloalias, $larghezzeutente)
20
    {
21 8
        if ((isset($larghezzeutente[$chiave])) && ($larghezzeutente[$chiave] != '') && ($larghezzeutente[$chiave] != 0)) {
22
            $widthcampo = $larghezzeutente[$chiave];
23
        } else {
24 8
            $widthcampo = GrigliaDatiMultiUtils::getWidthColonna($singoloalias, $colonna);
25
            //$widthcampo = isset($singoloalias['lunghezza']) ? $singoloalias['lunghezza'] :
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
26
            //($colonna['length'] * GrigliaUtils::MOLTIPLICATORELARGHEZZA > GrigliaUtils::LARGHEZZAMASSIMA ?
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
27
            //GrigliaUtils::LARGHEZZAMASSIMA :
28
            //$colonna['length'] * GrigliaUtils::MOLTIPLICATORELARGHEZZA);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
29
        }
30
31 8
        return $widthcampo;
32
    }
33
34
    public static function getIndiceModelloSelect(&$chiave, &$colonna, $singoloalias, $widthcampo)
35
    {
36
        return array(
37
            'name' => isset($singoloalias['nomecampo']) ? $singoloalias['nomecampo'] : $chiave,
38
            'id' => isset($singoloalias['nomecampo']) ? $singoloalias['nomecampo'] : $chiave,
39
            'width' => $widthcampo,
40
            'tipocampo' => isset($singoloalias['tipo']) ? $singoloalias['tipo'] : $colonna['type'],
41
            'editable' => isset($singoloalias['editable']) ? $singoloalias['editable'] : null,
42
            'editoptions' => $singoloalias['valoricombo'], );
43
    }
44
45 8
    public static function getIndiceModello(&$chiave, &$colonna, $singoloalias, $widthcampo)
46
    {
47
        return array(
48 8
            'name' => isset($singoloalias['nomecampo']) ? $singoloalias['nomecampo'] : $chiave,
49 8
            'id' => isset($singoloalias['nomecampo']) ? $singoloalias['nomecampo'] : $chiave,
50 8
            'width' => $widthcampo,
51 8
            'tipocampo' => isset($singoloalias['tipo']) ? $singoloalias['tipo'] : $colonna['type'],
52 8
            'editable' => isset($singoloalias['editable']) ? $singoloalias['editable'] : null,
53 8
        );
54
    }
55
56 8
    public static function setModelliColonne(&$modellocolonne, &$colonna, &$chiave, &$singoloalias, &$indicecolonna, $larghezzeutente)
57
    {
58 8
        $widthcampo = self::getWidthCampo($colonna, $chiave, $singoloalias, $larghezzeutente);
59
60 8
        if (isset($singoloalias['tipo']) && ($singoloalias['tipo'] == 'select')) {
61
            $modellocolonne[$indicecolonna] = self::getIndiceModelloSelect($chiave, $colonna, $singoloalias, $widthcampo);
62
        } else {
63 8
            $modellocolonne[$indicecolonna] = self::getIndiceModello($chiave, $colonna, $singoloalias, $widthcampo);
64
        }
65 8
    }
66
67 13
    public static function setNomiColonne(&$nomicolonne, &$chiave, &$singoloalias, &$indicecolonna, &$etichetteutente)
68
    {
69 13
        if ((isset($etichetteutente[$chiave])) && (trim($etichetteutente[$chiave]) != '')) {
70
            $nomicolonne[$indicecolonna] = self::getEtichettaNomeColonna($etichetteutente, $chiave);
71
        } else {
72 13
            $nomicolonne[$indicecolonna] = self::getEtichettaDescrizioneColonna($singoloalias, $chiave);
73
        }
74 13
    }
75
76
    public static function getOrdineColonne(&$chiave, &$indice, $ordinecolonne, &$indicecolonna)
77
    {
78
        $indicecolonna = array_search($chiave, $ordinecolonne);
79
        if ($indicecolonna === false) {
80
            if ($indice === 0) {
81
                $indice = count($ordinecolonne);
82
            }
83
            ++$indice;
84
            $indicecolonna = $indice;
85
        } else {
86
            if ($indicecolonna > $indice) {
87
                $indice = $indicecolonna;
88
            }
89
        }
90
    }
91
92 8
    public static function getSingoloAliasNormalizzato(&$singoloalias)
93
    {
94 8
        if (is_object($singoloalias)) {
95
            $singoloalias = get_object_vars($singoloalias);
96
        }
97 8
    }
98
99 13
    public static function setOrdineColonne(&$ordinecolonne, &$chiave, &$indice, &$indicecolonna)
100
    {
101 13
        if (isset($ordinecolonne)) {
102
            self::getOrdineColonne($chiave, $indice, $ordinecolonne, $indicecolonna);
103
        } else {
104 13
            ++$indice;
105 13
            $indicecolonna = $indice;
106
        }
107 13
    }
108
}
109