Passed
Push — master ( 051594...3fcc67 )
by Andrea
11:58
created

GrigliaDatiUtils::getDatiPrecondizioni()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Fi\CoreBundle\Utils;
4
5
class GrigliaDatiUtils
6
{
7
8 1
    public static function getTabellejNormalizzate($parametri)
9
    {
10 1
        $tabellej = (isset($parametri['tabellej']) ? $parametri['tabellej'] : null);
11 1
        if (is_object($tabellej)) {
12
            $tabellej = get_object_vars($tabellej);
13
        }
14
15 1
        return $tabellej;
16
    }
17
18 1
    public static function setTabelleJoin(&$q, $parametri = array())
19
    {
20 1
        $tabellej = $parametri['tabellej'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
21 1
        $nometabella = $parametri['nometabella'];
22
23 1
        foreach ($tabellej as $tabellaj) {
24 1
            if (is_object($tabellaj)) {
25
                $tabellaj = get_object_vars($tabellaj);
26
            }
27
            /* Serve per far venire nella getArrayResult() anche i campi della tabella il leftjoin
28
              altrimenti mostra solo quelli della tabella con alias a */
29 1
            $parametrotabella = array($tabellaj['tabella']);
30 1
            $tabellajoin = (isset($tabellaj['padre']) ? $tabellaj['padre'] : $nometabella) . '.' . $tabellaj['tabella'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
31 1
            $aliasjoin = $tabellaj['tabella'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
32 1
            $q->addSelect($parametrotabella);
33 1
            $q = $q->leftJoin($tabellajoin, $aliasjoin);
34 1
        }
35 1
    }
36
37 1
    public static function getDatiDecodifiche($parametri)
38
    {
39 1
        return isset($parametri['decodifiche']) ? $parametri['decodifiche'] : null;
40
    }
41
42 1
    public static function getDatiNospan($parametri)
43
    {
44 1
        return isset($parametri['nospan']) ? $parametri['nospan'] : false;
45
    }
46
47 1
    public static function getDatiPrecondizioni($parametri)
48
    {
49 1
        return isset($parametri['precondizioni']) ? $parametri['precondizioni'] : false;
50
    }
51
52 1
    public static function getDatiPrecondizioniAvanzate($parametri)
53
    {
54 1
        return isset($parametri['precondizioniAvanzate']) ? $parametri['precondizioniAvanzate'] : false;
55
    }
56
57 1
    public static function getDatiCampiExtra($parametri)
58
    {
59 1
        return isset($parametri['campiextra']) ? $parametri['campiextra'] : null;
60
    }
61
62 1
    public static function getDatiOrdineColonne($parametri)
63
    {
64 1
        $ordinecolonne = (isset($parametri['ordinecolonne']) ? $parametri['ordinecolonne'] : null);
65 1
        if (!isset($ordinecolonne)) {
66 1
            $ordinecolonne = GrigliaUtils::ordinecolonne($parametri);
67 1
        }
68
69 1
        return $ordinecolonne;
70
    }
71
72 1
    public static function getDatiOrdinamento(&$sidx, $nometabella)
73
    {
74
        /* se non è passato nessun campo (ipotesi peregrina) usa id */
75
76 1
        if (!$sidx) {
77 1
            $sidx = $nometabella . '.id';
78 1
        } elseif (strrpos($sidx, '.') == 0) {
79
            if (strrpos($sidx, ',') == 0) {
80
                // un solo campo
81
                $sidx = $nometabella . '.' . $sidx;
82
            }/* else {
83
              // NON FUNZIONA
84
              // più campi, passati separati da virgole
85
              $sidx = self::splitFiledOrderBy($nometabella);
86
              } */
87
        }
88 1
    }
89
90
    /* public static function splitFiledOrderBy($nometabella)
0 ignored issues
show
Unused Code Comprehensibility introduced by
49% 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...
91
      {
92
      $sidx = "";
93
      $parti = explode(',', $sidx);
94
      foreach ($parti as $parte) {
95
      if (trim($sidx) != '') {
96
      $sidx = $sidx . ',';
97
      }
98
      $sidx = $sidx . $nometabella . '.' . trim($parte);
99
      }
100
      return $sidx;
101
      } */
102
103 1
    public static function valorizzaVettore(&$vettoreriga, $parametri)
104
    {
105 1
        $tabella = $parametri['tabella'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
106 1
        $nomecampo = $parametri['nomecampo'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
107 1
        $doctrine = $parametri['doctrine'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
108 1
        $decodifiche = $parametri['decodifiche'];
109
110 1
        $vettoreparcampi = $doctrine->getMetadataFactory()->getMetadataFor($tabella)->fieldMappings;
111
112 1
        if (is_object($vettoreparcampi)) {
113
            $vettoreparcampi = get_object_vars($vettoreparcampi);
114
        }
115
116 1
        $singolocampo = $parametri['singolocampo'];
117
118 1
        if (isset($decodifiche[$nomecampo])) {
119
            $vettoreriga[] = $decodifiche[$nomecampo][$singolocampo];
120
        } else {
121 1
            $vettoretype = isset($vettoreparcampi[$nomecampo]['type']) ? $vettoreparcampi[$nomecampo]['type'] : null;
122 1
            self::valorizzaVettoreType($vettoreparcampi, $vettoreriga, $vettoretype, $parametri);
123
        }
124 1
    }
125
126 1
    public static function valorizzaVettoreType(&$vettoreparcampi, &$vettoreriga, $vettoretype, $parametri)
127
    {
128 1
        $nomecampo = $parametri['nomecampo'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
129 1
        $ordinecampo = $parametri['ordinecampo'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
130 1
        $singolocampo = $parametri['singolocampo'];
131
132 1
        if (self::isDateType($vettoretype, $singolocampo)) {
133 1
            if (isset($ordinecampo)) {
134 1
                $vettoreriga[$ordinecampo] = $singolocampo->format('d/m/Y');
135 1
            } else {
136
                $vettoreriga[] = $singolocampo->format('d/m/Y');
137
            }
138 1
        } elseif (self::isTimeType($vettoreparcampi, $vettoretype, $nomecampo, $singolocampo)) {
139
            if (isset($ordinecampo)) {
140
                $vettoreriga[$ordinecampo] = $singolocampo->format('H:i');
141
            } else {
142
                $vettoreriga[] = $singolocampo->format('H:i');
143
            }
144
        } else {
145 1
            if (isset($ordinecampo)) {
146 1
                $vettoreriga[$ordinecampo] = $singolocampo;
147 1
            } else {
148
                $vettoreriga[] = $singolocampo;
149
            }
150
        }
151 1
    }
152
153 1
    public static function isDateType($vettoretype, $singolocampo)
154
    {
155 1
        return isset($vettoretype) && ($vettoretype == 'date' || $vettoretype == 'datetime') && $singolocampo;
156
    }
157
158 1
    public static function isTimeType($vettoreparcampi, $vettoretype, $nomecampo, $singolocampo)
159
    {
160 1
        return isset($vettoretype) && ($vettoreparcampi[$nomecampo]['type'] == 'time') && $singolocampo;
161
    }
162
163 1
    public static function campoElencato($parametriCampoElencato)
164
    {
165 1
        $tabellej = $parametriCampoElencato['tabellej'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
166 1
        $nomecampo = $parametriCampoElencato['nomecampo'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
167 1
        $campoelencato = $parametriCampoElencato['campoelencato'];
168 1
        $vettoreriga = $parametriCampoElencato['vettoreriga'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
169 1
        $singolo = $parametriCampoElencato['singolo'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
170 1
        $doctrine = $parametriCampoElencato['doctrine'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
171 1
        $bundle = $parametriCampoElencato['bundle'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
172 1
        $decodifiche = $parametriCampoElencato['decodifiche'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
173
174 1
        if (isset($parametriCampoElencato['ordinecampo'])) {
175 1
            $ordinecampo = $parametriCampoElencato['ordinecampo'];
176 1
        } else {
177
            $ordinecampo = null;
178
        }
179
180 1
        if (isset($tabellej[$campoelencato])) {
181
            foreach ($tabellej[$campoelencato]['campi'] as $campoelencatointerno) {
182
                $parametriCampoElencatoInterno = array();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 18 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
183
                $parametriCampoElencatoInterno['tabellej'] = $tabellej;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
184
                $parametriCampoElencatoInterno['nomecampo'] = $campoelencato;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
185
                $parametriCampoElencatoInterno['campoelencato'] = $campoelencatointerno;
186
                $parametriCampoElencatoInterno['vettoreriga'] = $vettoreriga;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
187
                $parametriCampoElencatoInterno['singolo'] = $singolo;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
188
                $parametriCampoElencatoInterno['doctrine'] = $doctrine;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
189
                $parametriCampoElencatoInterno['bundle'] = $bundle;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
190
                $parametriCampoElencatoInterno['ordinecampo'] = $ordinecampo;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
191
                $parametriCampoElencatoInterno['decodifiche'] = $decodifiche;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
192
193
                $vettoreriga = self::campoElencato($parametriCampoElencatoInterno);
194
            }
195
        } else {
196 1
            if (isset($tabellej[$nomecampo]['padre'])) {
197
                $fields = $singolo[$tabellej[$nomecampo]['padre']][$tabellej[$nomecampo]['tabella']] ?
198
                        $singolo[$tabellej[$nomecampo]['padre']][$tabellej[$nomecampo]['tabella']][$campoelencato] :
199
                        '';
200
            } else {
201 1
                $fields = $singolo[$tabellej[$nomecampo]['tabella']] ?
202 1
                        $singolo[$tabellej[$nomecampo]['tabella']][$campoelencato] :
203 1
                        '';
204
            }
205
            $vettoredavalorizzare = array(
206 1
                'singolocampo' => $fields,
207 1
                'tabella' => $bundle . ':' . $tabellej[$nomecampo]['tabella'],
208 1
                'nomecampo' => $campoelencato,
209 1
                'doctrine' => $doctrine,
210 1
                'ordinecampo' => $ordinecampo,
211 1
                'decodifiche' => $decodifiche,
212 1
            );
213 1
            self::valorizzaVettore($vettoreriga, $vettoredavalorizzare);
214
        }
215
216 1
        return $vettoreriga;
217
    }
218
}
219