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

GrigliaInfoCampiUtils::getOrdineColonne()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 0
cts 13
cp 0
rs 9.2
c 0
b 0
f 0
cc 4
eloc 10
nc 4
nop 4
crap 20
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