Passed
Push — master ( 2a39ec...3b6c56 )
by Andrea
03:42
created

GrigliaInfoCampiUtils::getEtichettaNomeColonna()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Fi\CoreBundle\Utils;
4
5
class GrigliaInfoCampiUtils
6
{
7 19
    public static function getEtichettaDescrizioneColonna(&$singoloalias, $chiave)
8
    {
9 19
        $array = array('str' => $chiave, 'primamaiuscola' => true);
10
11 19
        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 12
    public static function getWidthCampo(&$colonna, &$chiave, $singoloalias, $larghezzeutente)
20
    {
21 12
        if ((isset($larghezzeutente[$chiave])) && ($larghezzeutente[$chiave] != '') && ($larghezzeutente[$chiave] != 0)) {
22
            $widthcampo = $larghezzeutente[$chiave];
23
        } else {
24 12
            $widthcampo = GrigliaDatiMultiUtils::getWidthColonna($singoloalias, $colonna);
25
            //($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...
26
            //GrigliaUtils::LARGHEZZAMASSIMA :
27
            //$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...
28
        }
29
30 12
        return $widthcampo;
31
    }
32
33 2
    public static function getIndiceModelloSelect(&$chiave, &$colonna, $singoloalias, $widthcampo)
34
    {
35
        return array(
36 2
            'name' => isset($singoloalias['nomecampo']) ? $singoloalias['nomecampo'] : $chiave,
37 2
            'id' => isset($singoloalias['nomecampo']) ? $singoloalias['nomecampo'] : $chiave,
38 2
            'width' => $widthcampo,
39 2
            'tipocampo' => isset($singoloalias['tipo']) ? $singoloalias['tipo'] : $colonna['type'],
40 2
            'editable' => isset($singoloalias['editable']) ? $singoloalias['editable'] : null,
41 2
            'editoptions' => $singoloalias['valoricombo'], );
42
    }
43
44 12
    public static function getIndiceModello(&$chiave, &$colonna, $singoloalias, $widthcampo)
45
    {
46
        return array(
47 12
            'name' => isset($singoloalias['nomecampo']) ? $singoloalias['nomecampo'] : $chiave,
48 12
            'id' => isset($singoloalias['nomecampo']) ? $singoloalias['nomecampo'] : $chiave,
49 12
            'width' => $widthcampo,
50 12
            'tipocampo' => isset($singoloalias['tipo']) ? $singoloalias['tipo'] : $colonna['type'],
51 12
            'editable' => isset($singoloalias['editable']) ? $singoloalias['editable'] : null,
52
        );
53
    }
54
55 12
    public static function setModelliColonne(&$modellocolonne, &$colonna, &$chiave, &$singoloalias, &$indicecolonna, $larghezzeutente)
56
    {
57 12
        $widthcampo = self::getWidthCampo($colonna, $chiave, $singoloalias, $larghezzeutente);
58
59 12
        if (isset($singoloalias['tipo']) && ($singoloalias['tipo'] == 'select')) {
60 2
            $modellocolonne[$indicecolonna] = self::getIndiceModelloSelect($chiave, $colonna, $singoloalias, $widthcampo);
61
        } else {
62 12
            $modellocolonne[$indicecolonna] = self::getIndiceModello($chiave, $colonna, $singoloalias, $widthcampo);
63
        }
64 12
    }
65
66 19
    public static function setNomiColonne(&$nomicolonne, &$chiave, &$singoloalias, &$indicecolonna, &$etichetteutente)
67
    {
68 19
        if ((isset($etichetteutente[$chiave])) && (trim($etichetteutente[$chiave]) != '')) {
69
            $nomicolonne[$indicecolonna] = self::getEtichettaNomeColonna($etichetteutente, $chiave);
70
        } else {
71 19
            $nomicolonne[$indicecolonna] = self::getEtichettaDescrizioneColonna($singoloalias, $chiave);
72
        }
73 19
    }
74
75 1
    public static function getOrdineColonne(&$chiave, &$indice, $ordinecolonne, &$indicecolonna)
76
    {
77 1
        $indicecolonna = array_search($chiave, $ordinecolonne);
78 1
        if ($indicecolonna === false) {
79 1
            if ($indice === 0) {
80 1
                $indice = count($ordinecolonne);
81
            }
82 1
            ++$indice;
83 1
            $indicecolonna = $indice;
84
        } else {
85 1
            if ($indicecolonna > $indice) {
86
                $indice = $indicecolonna;
87
            }
88
        }
89 1
    }
90
91 12
    public static function getSingoloAliasNormalizzato(&$singoloalias)
92
    {
93 12
        if (is_object($singoloalias)) {
94
            $singoloalias = get_object_vars($singoloalias);
95
        }
96 12
    }
97
98 19
    public static function setOrdineColonne(&$ordinecolonne, &$chiave, &$indice, &$indicecolonna)
99
    {
100 19
        if (isset($ordinecolonne)) {
101 1
            self::getOrdineColonne($chiave, $indice, $ordinecolonne, $indicecolonna);
102
        } else {
103 18
            ++$indice;
104 18
            $indicecolonna = $indice;
105
        }
106 19
    }
107
}
108