Passed
Push — master ( d65fb2...07d9b9 )
by Roberto
05:56 queued 03:13
created

TraitBlocoII::blocoII()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 91

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 91
ccs 0
cts 85
cp 0
crap 6
rs 8.1963
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 NFePHP\DA\NFe\Traits;
4
5
/**
6
 * Bloco sub cabecalho com a identificação e logo do emitente
7
 */
8
trait TraitBlocoII
9
{
10
    protected function blocoII($y)
11
    {
12
        $this->bloco2H = 12;
0 ignored issues
show
Bug introduced by
The property bloco2H does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
13
        
14
        //$aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => ''];
15
        //$this->pdf->textBox($this->margem, $y, $this->wPrint, $this->bloco2H, '', $aFont, 'T', 'C', true, '', false);
16
        
17
        if ($this->tpEmis == 9) {
0 ignored issues
show
Bug introduced by
The property tpEmis does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
18
            $texto = "Documento Auxiliar da Nota Fiscal de Consumidor Eletronica";
19
            $aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => ''];
0 ignored issues
show
Bug introduced by
The property fontePadrao does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20
            $y1 = $this->pdf->textBox(
0 ignored issues
show
Bug introduced by
The property pdf does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
21
                $this->margem,
0 ignored issues
show
Bug introduced by
The property margem does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
22
                $y,
23
                $this->wPrint,
0 ignored issues
show
Bug introduced by
The property wPrint does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
24
                $this->bloco2H,
25
                $texto,
26
                $aFont,
27
                'T',
28
                'C',
29
                false,
30
                '',
31
                true
32
            );
33
            $texto = "Não permite aproveitamento de crédito de ICMS";
34
            $aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => ''];
35
            $y1 += $this->pdf->textBox(
36
                $this->margem,
37
                $y+$y1,
38
                $this->wPrint,
39
                2,
40
                $texto,
41
                $aFont,
42
                'T',
43
                'C',
44
                false,
45
                '',
46
                true
47
            );
48
            //contingencia offline
49
            $texto = "EMITIDA EM CONTINGÊNCIA";
50
            $aFont = ['font'=> $this->fontePadrao, 'size' => 10, 'style' => 'B'];
51
            $y2 = $this->pdf->textBox(
52
                $this->margem,
53
                $y+$y1,
54
                $this->wPrint,
55
                4,
56
                $texto,
57
                $aFont,
58
                'B',
59
                'C',
60
                false,
61
                '',
62
                true
63
            );
64
            
65
            $texto = "Pendente de autorização";
66
            $aFont = ['font'=> $this->fontePadrao, 'size' => 8, 'style' => 'I'];
67
            $this->pdf->textBox(
68
                $this->margem,
69
                $y+$y1+$y2,
70
                $this->wPrint,
71
                3,
72
                $texto,
73
                $aFont,
74
                'B',
75
                'C',
76
                false,
77
                '',
78
                true
79
            );
80
        } else {
81
            $texto = "Documento Auxiliar da Nota Fiscal de Consumidor Eletronica\n"
82
                . "Não permite aproveitamento de crédito de ICMS";
83
            $aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => ''];
84
            $y1 = $this->pdf->textBox(
0 ignored issues
show
Unused Code introduced by
$y1 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
85
                $this->margem,
86
                $this->bloco1H-2,
0 ignored issues
show
Bug introduced by
The property bloco1H does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
87
                $this->wPrint,
88
                $this->bloco2H,
89
                $texto,
90
                $aFont,
91
                'C',
92
                'C',
93
                false,
94
                '',
95
                true
96
            );
97
        }
98
        $this->pdf->dashedHLine($this->margem, $this->bloco2H+$y, $this->wPrint, 0.1, 30);
99
        return $this->bloco2H + $y;
100
    }
101
}
102