Passed
Push — master ( c09f3d...b68917 )
by Andrea
12:33
created

GrigliaUtils::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 70
Code Lines 54

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 57
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 54
nc 1
nop 0
dl 0
loc 70
ccs 57
cts 57
cp 1
crap 1
rs 9.1724
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Fi\CoreBundle\Utils;
4
5
class GrigliaUtils
6
{
7
8
    public static $decodificaop;
9
    public static $precarattere;
10
    public static $postcarattere;
11
12
    const LARGHEZZAMASSIMA = 500;
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...
13
    const MOLTIPLICATORELARGHEZZA = 10;
14
15 1
    public static function init()
16
    {
17
        // i possibili operatori di ciascuna ricerca sono
18
        //questi: ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc', 'nu', 'nn']
0 ignored issues
show
Unused Code Comprehensibility introduced by
90% 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...
19
        //significano questo
20
        //['equal','not equal', 'less', 'less or equal','greater','greater or equal',
0 ignored issues
show
Unused Code Comprehensibility introduced by
87% 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...
21
        //'begins with','does not begin with','is in','is not in','ends with','does not end with',
0 ignored issues
show
Unused Code Comprehensibility introduced by
100% 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...
22
        //'contains','does not contain', 'is null', 'is not null']
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% 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...
23
        //sulla base dell'operatore impostato per la singola ricerca si impostano tre vettori
24
        //il promo contiene l'operatore da usare in query
25
26 1
        self::$decodificaop = array(
27 1
            'eq' => '=',
28 1
            'ne' => '<>',
29 1
            'lt' => '<',
30 1
            'le' => '<=',
31 1
            'gt' => '>',
32 1
            'ge' => '>=',
33 1
            'bw' => 'LIKE',
34 1
            'bn' => 'NOT LIKE',
35 1
            'in' => 'IN',
36 1
            'ni' => 'NOT IN',
37 1
            'ew' => 'LIKE',
38 1
            'en' => 'NOT LIKE',
39 1
            'cn' => 'LIKE',
40 1
            'nc' => 'NOT LIKE',
41 1
            'nu' => 'IS',
42 1
            'nn' => 'IS NOT',
43 1
            'nt' => '<>',
44 1
        );
45
        // questo contiene il carattere da usare prima del campo dati in query dipendentemente dal tipo di operatore
46 1
        self::$precarattere = array(
47 1
            'eq' => '',
48 1
            'ne' => '',
49 1
            'lt' => '',
50 1
            'le' => '',
51 1
            'gt' => '',
52 1
            'ge' => '',
53 1
            'bw' => 'lower(\'',
54 1
            'bn' => 'lower(\'',
55 1
            'in' => '(',
56 1
            'ni' => '(',
57 1
            'ew' => 'lower(\'%',
58 1
            'en' => 'lower(\'%',
59 1
            'cn' => 'lower(\'%',
60 1
            'nc' => 'lower(\'%',
61 1
            'nu' => 'NULL',
62 1
            'nn' => 'NULL',
63 1
            'nt' => 'TRUE',
64 1
        );
65
66
        // questo contiene il carattere da usare dopo il campo dati in query dipendentemente dal tipo di operatore
67 1
        self::$postcarattere = array(
68 1
            'eq' => '',
69 1
            'ne' => '',
70 1
            'lt' => '',
71 1
            'le' => '',
72 1
            'gt' => '',
73 1
            'ge' => '',
74 1
            'bw' => '%\')',
75 1
            'bn' => '%\')',
76 1
            'in' => ')',
77 1
            'ni' => ')',
78 1
            'ew' => '\')',
79 1
            'en' => '\')',
80 1
            'cn' => '%\')',
81 1
            'nc' => '%\')',
82 1
            'nu' => '',
83 1
            'nn' => '',
84 1
            'nt' => '',);
85 1
    }
86
87 1
    public static function setVettoriPerData()
88
    {
89 1
        self::$precarattere['eq'] = "'";
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...
90 1
        self::$precarattere['ne'] = "'";
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...
91 1
        self::$precarattere['lt'] = "'";
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...
92 1
        self::$precarattere['le'] = "'";
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 1
        self::$precarattere['gt'] = "'";
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...
94 1
        self::$precarattere['ge'] = "'";
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...
95 1
        self::$postcarattere['eq'] = "'";
96 1
        self::$postcarattere['ne'] = "'";
97 1
        self::$postcarattere['lt'] = "'";
98 1
        self::$postcarattere['le'] = "'";
99 1
        self::$postcarattere['gt'] = "'";
100 1
        self::$postcarattere['ge'] = "'";
101 1
    }
102
103
    public static function setVettoriPerBoolean()
104
    {
105
        self::setVettoriPerData();
106
    }
107
108 1
    public static function setVettoriPerStringa()
109
    {
110 1
        self::$precarattere['eq'] = "lower('";
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...
111 1
        self::$precarattere['ne'] = "lower('";
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...
112 1
        self::$precarattere['lt'] = "lower('";
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...
113 1
        self::$precarattere['le'] = "lower('";
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...
114 1
        self::$precarattere['gt'] = "lower('";
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...
115 1
        self::$precarattere['ge'] = "lower('";
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...
116 1
        self::$postcarattere['eq'] = "')";
117 1
        self::$postcarattere['ne'] = "')";
118 1
        self::$postcarattere['lt'] = "')";
119 1
        self::$postcarattere['le'] = "')";
120 1
        self::$postcarattere['gt'] = "')";
121 1
        self::$postcarattere['ge'] = "')";
122 1
    }
123
124 1
    public static function setVettoriPerNumero()
125
    {
126 1
        self::$precarattere['eq'] = '';
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...
127 1
        self::$precarattere['ne'] = '';
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...
128 1
        self::$precarattere['lt'] = '';
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...
129 1
        self::$precarattere['le'] = '';
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
        self::$precarattere['gt'] = '';
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...
131 1
        self::$precarattere['ge'] = '';
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...
132 1
        self::$postcarattere['eq'] = '';
133 1
        self::$postcarattere['ne'] = '';
134 1
        self::$postcarattere['lt'] = '';
135 1
        self::$postcarattere['le'] = '';
136 1
        self::$postcarattere['gt'] = '';
137 1
        self::$postcarattere['ge'] = '';
138 1
    }
139
140 4
    public static function getCampiEsclusi($riga, $output)
141
    {
142 4
        $campoescluso = null;
143 4
        if ($output == 'stampa') {
144
            if ($riga->hasMostrastampa() == false) {
145
                $campoescluso = $riga->getNomecampo();
146
            }
147
        } else {
148 4
            if ($riga->hasMostraindex() == false) {
149
                $campoescluso = $riga->getNomecampo();
150
            }
151
        }
152
153 4
        return $campoescluso;
154
    }
155
156 13
    public static function getUserCustomTableFields($em, $nometabella, $operatore)
157
    {
158 13
        $q = $em->getRepository('FiCoreBundle:Tabelle')->findBy(array('operatori_id' => $operatore['id'], 'nometabella' => $nometabella));
159
160 13
        if (!$q) {
161 13
            unset($q);
162 13
            $q = $em->getRepository('FiCoreBundle:Tabelle')->findBy(array('operatori_id' => null, 'nometabella' => $nometabella));
163 13
        }
164
165 13
        return $q;
166
    }
167
168 13
    public static function etichettecampi($parametri = array())
169
    {
170 13
        if (!isset($parametri['nometabella'])) {
171
            return false;
172
        }
173
174 13
        $output = GrigliaParametriUtils::getOuputType($parametri);
175
176 13
        $nometabella = $parametri['nometabella'];
177
178 13
        $doctrine = GrigliaParametriUtils::getDoctrineByEm($parametri);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 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...
179 13
        $doctrineficore = GrigliaParametriUtils::getDoctrineFiCoreByEm($parametri, $doctrine);
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...
180 13
        $container = $parametri['container'];
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...
181 13
        $gestionepermessi = $container->get("ficorebundle.gestionepermessi");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal ficorebundle.gestionepermessi 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...
182
183 13
        $operatorecorrente = $gestionepermessi->utentecorrente();
184
185 13
        $etichette = array();
186
187 13
        $q = self::getUserCustomTableFields($doctrineficore, $nometabella, $operatorecorrente);
188
189 13
        if ($q) {
190 4
            foreach ($q as $riga) {
191 4
                if ($output == 'stampa') {
192
                    $etichette[$riga->getNomecampo()] = $riga->getEtichettastampa();
193
                } else {
194 4
                    $etichette[$riga->getNomecampo()] = $riga->getEtichettaindex();
195
                }
196 4
            }
197 4
        }
198
199 13
        return $etichette;
200
    }
201
202 13
    public static function larghezzecampi($parametri = array())
203
    {
204 13
        if (!isset($parametri['nometabella'])) {
205
            return false;
206
        }
207
208 13
        $output = GrigliaParametriUtils::getOuputType($parametri);
209
210 13
        $nometabella = $parametri['nometabella'];
211
212 13
        $doctrine = GrigliaParametriUtils::getDoctrineByEm($parametri);
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...
213 13
        $doctrineficore = GrigliaParametriUtils::getDoctrineFiCoreByEm($parametri, $doctrine);
214
215 13
        $container = $parametri['container'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 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...
216 13
        $gestionepermessi = $container->get("ficorebundle.gestionepermessi");
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...
Coding Style Comprehensibility introduced by
The string literal ficorebundle.gestionepermessi 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...
217 13
        $operatorecorrente = $gestionepermessi->utentecorrente();
218
219 13
        $etichette = array();
220
221 13
        $q = self::getUserCustomTableFields($doctrineficore, $nometabella, $operatorecorrente);
222
223 13
        if (!$q) {
224 9
            return $etichette;
225
        }
226
227 4
        foreach ($q as $riga) {
228 4
            if ($output == 'stampa') {
229
                $etichette[$riga->getNomecampo()] = $riga->getLarghezzastampa();
230
            } else {
231 4
                $etichette[$riga->getNomecampo()] = $riga->getLarghezzaindex();
232
            }
233 4
        }
234
235 4
        return $etichette;
236
    }
237
238 13
    public static function ordinecolonne($parametri = array())
239
    {
240 13
        if (!isset($parametri['nometabella'])) {
241
            return false;
242
        }
243
244 13
        $output = GrigliaParametriUtils::getOuputType($parametri);
245
246 13
        $nometabella = $parametri['nometabella'];
247
248 13
        $doctrine = GrigliaParametriUtils::getDoctrineByEm($parametri);
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...
249 13
        $doctrineficore = GrigliaParametriUtils::getDoctrineFiCoreByEm($parametri, $doctrine);
250 13
        $container = $parametri['container'];
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...
251
252 13
        $gestionepermessi = $container->get("ficorebundle.gestionepermessi");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal ficorebundle.gestionepermessi 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...
253
254 13
        $operatorecorrente = $gestionepermessi->utentecorrente();
255
256 13
        $ordine = array();
257
258 13
        $q = self::getUserCustomTableFields($doctrineficore, $nometabella, $operatorecorrente);
259
260 13
        if ($q) {
261 4
            foreach ($q as $riga) {
262 4
                if ($output == 'stampa') {
263
                    if ($riga->getOrdinestampa()) {
264
                        $ordine[$riga->getOrdinestampa()] = $riga->getNomecampo();
265
                    }
266
                } else {
267 4
                    if ($riga->getOrdineindex()) {
268
                        $ordine[$riga->getOrdineindex()] = $riga->getNomecampo();
269
                    }
270
                }
271 4
            }
272 4
            if (count($ordine) > 0) {
273
                ksort($ordine);
274
            }
275 4
        }
276
277 13
        $ordinecolonne = GrigliaColonneUtils::getColonneOrdinate($ordine);
278
279 13
        return $ordinecolonne;
280
    }
281
282
    /**
283
     * Translates a string with underscores into camel case (e.g. first_name -&gt; firstName).
284
     *
285
     * @param array  $parametri
286
     *
287
     * @return string $str translated into camel caps
288
     */
289 13
    public static function toCamelCase($parametri = array())
290
    {
291 13
        $str = $parametri['str'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 19 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...
292 13
        $capitalise_first_char = isset($parametri['primamaiuscola']) ? $parametri['primamaiuscola'] : false;
293
294 13
        if ($capitalise_first_char) {
295 13
            $str[0] = strtoupper($str[0]);
296 13
        }
297 13
        $func = function ($matches) {
298 4
            return strtoupper($matches[1]);
299 13
        };
300
301 13
        return preg_replace_callback('/_([a-z])/', $func, $str);
302
    }
303
304 13
    public static function getOpzioniTabella($doctrineficore, $nometabella, &$testata)
305
    {
306
        /* @var $qb \Doctrine\ORM\QueryBuilder */
307 13
        $qb = $doctrineficore->createQueryBuilder();
308 13
        $qb->select(array('a'));
309 13
        $qb->from('FiCoreBundle:OpzioniTabella', 'a');
310 13
        $qb->leftJoin('a.tabelle', 't');
311 13
        $qb->where("t.nometabella = '*' or t.nometabella = :tabella");
312 13
        $qb->andWhere("t.nomecampo is null or t.nomecampo = ''");
313 13
        $qb->orderBy('t.nometabella');
314 13
        $qb->setParameter('tabella', $nometabella);
315 13
        $opzioni = $qb->getQuery()->getResult();
316 13
        foreach ($opzioni as $opzione) {
317 13
            $testata[$opzione->getParametro()] = str_replace('%tabella%', $nometabella, $opzione->getValore());
318 13
        }
319 13
    }
320
321 13
    public static function getNomiColonne($nomicolonne)
322
    {
323 13
        ksort($nomicolonne);
324 13
        $nomicolonnesorted = array();
325 13
        foreach ($nomicolonne as $value) {
326 13
            $nomicolonnesorted[] = $value;
327 13
        }
328
329 13
        return $nomicolonnesorted;
330
    }
331
332 13
    public static function getModelloColonne($modellocolonne)
333
    {
334 13
        ksort($modellocolonne);
335 13
        $modellocolonnesorted = array();
336 13
        foreach ($modellocolonne as $value) {
337 13
            $modellocolonnesorted[] = $value;
338 13
        }
339
340 13
        return $modellocolonnesorted;
341
    }
342
343 13
    public static function getPermessiTabella($paricevuti, &$testata)
344
    {
345 13
        if (!isset($paricevuti['container'])) {
346
            return;
347
        }
348
349 13
        $container = $paricevuti['container'];
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...
350 13
        $nometabella = $paricevuti['nometabella'];
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...
351 13
        $gestionepermessi = $container->get("ficorebundle.gestionepermessi");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal ficorebundle.gestionepermessi 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...
352
353 13
        $vettorepermessi = $gestionepermessi->impostaPermessi(array('modulo' => $nometabella));
354
355 13
        return array_merge($testata, $vettorepermessi);
356
    }
357
}
358