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

GrigliaDatiUtils::getDatiNospan()   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 6
    public static function getTabellejNormalizzate($parametri)
9
    {
10 6
        $tabellej = (isset($parametri['tabellej']) ? $parametri['tabellej'] : null);
11 6
        if (is_object($tabellej)) {
12
            $tabellej = get_object_vars($tabellej);
13
        }
14
15 6
        return $tabellej;
16
    }
17
18 4
    public static function setTabelleJoin(&$q, $parametri = array())
19
    {
20 4
        $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 4
        $nometabella = $parametri['nometabella'];
22
23 4
        foreach ($tabellej as $tabellaj) {
24 4
            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 4
            $parametrotabella = array($tabellaj['tabella']);
30 4
            $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 4
            $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 4
            $q->addSelect($parametrotabella);
33 4
            $q = $q->leftJoin($tabellajoin, $aliasjoin);
34
        }
35 4
    }
36
37 6
    public static function getDatiDecodifiche($parametri)
38
    {
39 6
        return isset($parametri['decodifiche']) ? $parametri['decodifiche'] : null;
40
    }
41
42 6
    public static function getDatiNospan($parametri)
43
    {
44 6
        return isset($parametri['nospan']) ? $parametri['nospan'] : false;
45
    }
46
47 6
    public static function getDatiPrecondizioni($parametri)
48
    {
49 6
        return isset($parametri['precondizioni']) ? $parametri['precondizioni'] : array();
50
    }
51
52 6
    public static function getDatiPrecondizioniAvanzate($parametri)
53
    {
54 6
        return isset($parametri['precondizioniAvanzate']) ? $parametri['precondizioniAvanzate'] : array();
55
    }
56
57 6
    public static function getDatiCampiExtra($parametri)
58
    {
59 6
        return isset($parametri['campiextra']) ? $parametri['campiextra'] : null;
60
    }
61
62 6
    public static function getDatiOrdineColonne($parametri)
63
    {
64 6
        $ordinecolonne = (isset($parametri['ordinecolonne']) ? $parametri['ordinecolonne'] : null);
65 6
        if (!isset($ordinecolonne)) {
66 5
            $ordinecolonne = GrigliaUtils::ordinecolonne($parametri);
67
        }
68
69 6
        return $ordinecolonne;
70
    }
71
72 6
    public static function getDatiOrdinamento(&$sidx, $nometabella)
73
    {
74
        /* se non è passato nessun campo (ipotesi peregrina) usa id */
75 6
        if (!$sidx) {
76 4
            $sidx = $nometabella . '.id';
77 4
            return ;
78
        }
79 2
        if (strrpos($sidx, '.') == 0) {
80 2
            if (strrpos($sidx, ',') == 0) {
81
                // un solo campo
82 2
                $sidx = $nometabella . '.' . $sidx;
83
            } else {
84
                // più campi, passati separati da virgole
85
                $sidx = self::splitFiledOrderBy($sidx, $nometabella);
86
            }
87
        }
88 2
    }
89
90
    public static function splitFiledOrderBy($sidx, $nometabella)
91
    {
92
        $parti = explode(',', $sidx);
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...
93
        $neword = "";
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
94
        foreach ($parti as $parte) {
95
            if (trim($neword) != '') {
96
                $neword = $neword . ', ';
97
            }
98
            $neword = $neword . $nometabella . '.' . trim($parte);
99
        }
100
        return $neword;
101
    }
102
103 6
    public static function valorizzaVettore(&$vettoreriga, $parametri)
104
    {
105 6
        GrigliaExtraFunzioniUtils::valorizzaColonna($vettoreriga, $parametri);
106 6
    }
107
108 3
    public static function campoElencato($parametriCampoElencato)
109
    {
110 3
        $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...
111 3
        $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...
112 3
        $campoelencato = $parametriCampoElencato['campoelencato'];
113 3
        $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...
114 3
        $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...
115 3
        $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...
116 3
        $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...
117 3
        $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...
118
119 3
        if (isset($parametriCampoElencato['ordinecampo'])) {
120 3
            $ordinecampo = $parametriCampoElencato['ordinecampo'];
121
        } else {
122
            $ordinecampo = null;
123
        }
124
125 3
        if (isset($tabellej[$campoelencato])) {
126
            foreach ($tabellej[$campoelencato]['campi'] as $campoelencatointerno) {
127
                $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...
128
                $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...
129
                $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...
130
                $parametriCampoElencatoInterno['campoelencato'] = $campoelencatointerno;
131
                $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...
132
                $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...
133
                $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...
134
                $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...
135
                $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...
136
                $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...
137
138
                $vettoreriga = self::campoElencato($parametriCampoElencatoInterno);
139
            }
140
        } else {
141 3
            if (isset($tabellej[$nomecampo]['padre'])) {
142
                $fields = $singolo[$tabellej[$nomecampo]['padre']][$tabellej[$nomecampo]['tabella']] ?
143
                        $singolo[$tabellej[$nomecampo]['padre']][$tabellej[$nomecampo]['tabella']][$campoelencato] :
144
                        '';
145
            } else {
146 3
                $fields = $singolo[$tabellej[$nomecampo]['tabella']] ?
147 3
                        $singolo[$tabellej[$nomecampo]['tabella']][$campoelencato] :
148 3
                        '';
149
            }
150
            $vettoredavalorizzare = array(
151 3
                'singolocampo' => $fields,
152 3
                'tabella' => $bundle . ':' . $tabellej[$nomecampo]['tabella'],
153 3
                'nomecampo' => $campoelencato,
154 3
                'doctrine' => $doctrine,
155 3
                'ordinecampo' => $ordinecampo,
156 3
                'decodifiche' => $decodifiche,
157
            );
158 3
            self::valorizzaVettore($vettoreriga, $vettoredavalorizzare);
159
        }
160
161 3
        return $vettoreriga;
162
    }
163
}
164