Passed
Push — master ( 1e8655...fbfe4b )
by Andrea
17:02
created

buildOpzioneTabellaFromCore()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 5
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Cdf\BiCoreBundle\Utils\Tabella;
4
5
use Cdf\BiCoreBundle\Entity\Opzionitabelle;
6
use Cdf\BiCoreBundle\Entity\Colonnetabelle;
7
8
trait TabellaOpzioniFromCoreTrait
9
{
10 12
    protected function getOpzionitabellaFromCore()
11
    {
12 12
        $repoopzionitabelle = $this->em->getRepository(Opzionitabelle::class);
13 12
        $repocolonnetabelle = $this->em->getRepository(Colonnetabelle::class);
14 12
        $opzionitabella = $repoopzionitabelle->findOpzioniTabella($this->tablename);
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...
15 12
        $colonnetabella = $repocolonnetabelle->findOpzioniColonnetabella($this->tablename, $this->user);
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...
16
17 12
        return array('opzionitabella' => $opzionitabella, 'colonnetabella' => $colonnetabella);
18
    }
19
20 12
    protected function setOpzioniTabellaFromCore($colonnadatabase, &$opzionibuilder)
21
    {
22 12
        $colonnetabellacore = $this->opzionitabellacore['colonnetabella'];
23
        //$nomecolonna = $this->tablename . "." . $colonnadatabase["fieldName"];
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% 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...
24
        /* @var $colonnatabellacore \Cdf\BiCoreBundle\Entity\Colonnetabelle */
25 12
        foreach ($colonnetabellacore as $colonnatabellacore) {
26 3
            $campodabonificare = $colonnatabellacore->getNometabella().'.'.$colonnatabellacore->getNomecampo();
27 3
            $campo = $this->bonificaNomeCampo($campodabonificare);
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

27
            /** @scrutinizer ignore-call */ 
28
            $campo = $this->bonificaNomeCampo($campodabonificare);
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 13 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...
28 3
            $this->buildOpzioneTabellaFromCore($campo, 'etichetta', 'getEtichettaindex', $colonnatabellacore, $opzionibuilder);
29 3
            $this->buildOpzioneTabellaFromCore($campo, 'larghezza', 'getLarghezzaindex', $colonnatabellacore, $opzionibuilder);
30 3
            $this->buildOpzioneTabellaFromCore($campo, 'escluso', 'getMostraindex', $colonnatabellacore, $opzionibuilder);
31 3
            $this->buildOpzioneTabellaFromCore($campo, 'editabile', 'getEditabile', $colonnatabellacore, $opzionibuilder);
32 3
            $this->buildOpzioneTabellaFromCore($campo, 'ordine', 'getOrdineindex', $colonnatabellacore, $opzionibuilder);
33 3
            $opzionibuilder[$campo]['campoextra'] = false;
34
        }
35 12
    }
36
37 3
    protected function buildOpzioneTabellaFromCore($campo, $modellocolonneindex, $entityproperty, $colonnatabellacore, &$opzionibuilder)
38
    {
39 3
        if (null !== ($colonnatabellacore->$entityproperty())) {
40 3
            $opzionibuilder[$campo][$modellocolonneindex] = $colonnatabellacore->$entityproperty();
41
        }
42 3
    }
43
}
44