Passed
Push — master ( ce89ba...4bc45e )
by Andrea
11:12
created

GrigliaCampiExtraUtils   A

Complexity

Total Complexity 23

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Test Coverage

Coverage 88.14%

Importance

Changes 0
Metric Value
wmc 23
dl 0
loc 96
ccs 52
cts 59
cp 0.8814
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getCampiExtraDatiPerGriglia() 0 11 4
A getCampiExtraNomiColonne() 0 5 2
A getCampiExtraTipoColonna() 0 3 2
B getCampiExtraTestataPerGriglia() 0 26 3
A getCampiExtraNomeCampoColonna() 0 3 2
A getCampiExtraIdCampoColonna() 0 3 2
A getCampiExtraWidthColonna() 0 5 2
A getCampiExtraColonneNormalizzate() 0 4 2
A getCampiExtraNormalizzati() 0 12 4
1
<?php
2
3
namespace Fi\CoreBundle\Utils;
4
5
class GrigliaCampiExtraUtils
6
{
7
8 5
    public static function getCampiExtraNormalizzati(&$campiextra)
9
    {
10
        /* Se è un array di una dimensione si trasforma in bidimensionale */
11 5
        if (count($campiextra) == count($campiextra, \COUNT_RECURSIVE)) {
12 1
            $campoextraarray = $campiextra;
13 1
            $campiextra = array();
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...
14 1
            foreach ($campoextraarray as $key => $campoextranormalize) {
15
                if (is_object($campoextranormalize)) {
16
                    $campoextranormalize = get_object_vars($campoextranormalize);
17
                    $campiextra[] = $campoextranormalize;
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...
18
                } else {
19
                    $campiextra[] = array($key => $campoextranormalize);
20
                }
21 1
            }
22 1
        }
23 5
    }
24
25 13
    public static function getCampiExtraTestataPerGriglia($paricevuti, &$indice, &$nomicolonne, &$modellocolonne)
26
    {
27 13
        $campiextra = GrigliaParametriUtils::getParametriCampiExtraTestataPerGriglia($paricevuti);
28 13
        if (!isset($campiextra)) {
29 9
            return;
30
        }
31 4
        self::getCampiExtraNormalizzati($campiextra);
32
33 4
        foreach ($campiextra as $chiave => $colonna) {
34 4
            ++$indice;
35 4
            self::getCampiExtraColonneNormalizzate($colonna);
36
37 4
            $nomicolonne[$indice] = self::getCampiExtraNomiColonne($colonna, $chiave);
38
39 4
            $widthcolonna = self::getCampiExtraWidthColonna($colonna);
40
41 4
            $tipocolonna = self::getCampiExtraTipoColonna($colonna);
42 4
            $idcolonna = self::getCampiExtraNomeCampoColonna($colonna, $chiave);
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...
43 4
            $nomecolonna = self::getCampiExtraIdCampoColonna($colonna, $chiave);
44
45 4
            $modellocolonne[$indice] = array(
46 4
                'name' => $nomecolonna,
47 4
                'id' => $idcolonna,
48 4
                'width' => $widthcolonna,
49 4
                'tipocampo' => $tipocolonna,
50 4
                'search' => false,);
51 4
        }
52 4
    }
53
54 4
    public static function getCampiExtraIdCampoColonna($colonna, $chiave)
55
    {
56 4
        return isset($colonna['nomecampo']) ? $colonna['nomecampo'] : $chiave;
57
    }
58
59 4
    public static function getCampiExtraTipoColonna($colonna)
60
    {
61 4
        return isset($colonna['tipo']) ? $colonna['tipo'] : $colonna['type'];
62
    }
63
64 4
    public static function getCampiExtraNomeCampoColonna($colonna, $chiave)
65
    {
66 4
        return isset($colonna['nomecampo']) ? $colonna['nomecampo'] : $chiave;
67
    }
68
69 4
    public static function getCampiExtraNomiColonne(&$colonna, $chiave)
70
    {
71 4
        $parametri = array('str' => $chiave, 'primamaiuscola' => true);
72
73 4
        return isset($colonna['descrizione']) ? $colonna['descrizione'] : GrigliaUtils::toCamelCase($parametri);
74
    }
75
76 4
    public static function getCampiExtraWidthColonna($colonna)
77
    {
78 4
        $width = isset($colonna['lunghezza']) ? $colonna['lunghezza'] : GrigliaUtils::LARGHEZZAMASSIMA;
79
80 4
        return $width;
81
    }
82
83 4
    public static function getCampiExtraColonneNormalizzate(&$colonna)
84
    {
85 4
        if (is_object($colonna)) {
86
            $colonna = get_object_vars($colonna);
87
        }
88 4
    }
89
90 2
    public static function getCampiExtraDatiPerGriglia(&$campiextra, &$vettoreriga, $doctrine, $entityName, $singolo)
91
    {
92
        /* Gestione per passare campi che non sono nella tabella ma metodi del model (o richiamabili tramite magic method get) */
93 2
        if (isset($campiextra)) {
94 2
            GrigliaCampiExtraUtils::getCampiExtraNormalizzati($campiextra);
95 2
            foreach ($campiextra as $vettore) {
96 1
                foreach ($vettore as $singolocampo) {
97 1
                    $campo = 'get' . ucfirst($singolocampo);
98
                    /* @var $doctrine \Doctrine\ORM\EntityManager */
99 1
                    $objTabella = $doctrine->find($entityName, $singolo['id']);
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...
100 1
                    $vettoreriga[] = $objTabella->$campo();
101 1
                }
102 2
            }
103 2
        }
104 2
    }
105
}
106