Passed
Push — master ( 80923f...9fa0e9 )
by Andrea
16:11
created

TabellaOpzioniFromModelloColonneTrait   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 27
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0
wmc 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setOpzioniTabellaFromModellocolonne() 0 11 4
A checkCampoOpzioniTabella() 0 10 4
1
<?php
2
3
namespace Cdf\BiCoreBundle\Utils\Tabella;
4
5
trait TabellaOpzioniFromModelloColonneTrait
6
{
7 12
    protected function setOpzioniTabellaFromModellocolonne(&$opzionibuilder)
8
    {
9 12
        foreach ($this->modellocolonne as $modellocolonna) {
10 4
            $campo = $this->bonificaNomeCampo($modellocolonna['nomecampo']);
0 ignored issues
show
Bug introduced by
It seems like bonificaNomeCampo() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

10
            /** @scrutinizer ignore-call */ 
11
            $campo = $this->bonificaNomeCampo($modellocolonna['nomecampo']);
Loading history...
11 4
            $this->getOpzionitabellaCampiExtra($campo, $modellocolonna, $opzionibuilder);
0 ignored issues
show
Bug introduced by
It seems like getOpzionitabellaCampiExtra() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

11
            $this->/** @scrutinizer ignore-call */ 
12
                   getOpzionitabellaCampiExtra($campo, $modellocolonna, $opzionibuilder);
Loading history...
12 4
            foreach ($modellocolonna as $key => $value) {
13 4
                $this->checkCampoOpzioniTabella($campo, $modellocolonna, $opzionibuilder);
14 4
                if ('ordine' == $key) {
15 3
                    $this->setMaxOrdine($value);
0 ignored issues
show
Bug introduced by
It seems like setMaxOrdine() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

15
                    $this->/** @scrutinizer ignore-call */ 
16
                           setMaxOrdine($value);
Loading history...
16
                }
17 4
                $opzionibuilder[$campo][$key] = $value;
18
            }
19
        }
20 12
    }
21
22 4
    protected function checkCampoOpzioniTabella($campo, $modellocolonna, &$opzionibuilder)
23
    {
24 4
        if (!array_key_exists($campo, $opzionibuilder)) {
25 1
            if ((isset($modellocolonna['campoextra']) && true == $modellocolonna['campoextra'])) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
26
                // tuttapposto
27
            } else {
28 1
                $ex = 'BiCore: '.$campo." field table option not found, did you mean one of these:\n".
29 1
                        implode("\n", array_keys($opzionibuilder)).
30 1
                        ' ?';
31 1
                throw new \Exception($ex);
32
            }
33
        }
34 4
    }
35
}
36