Completed
Push — master ( c36dee...d1009b )
by Roberto
03:31 queued 11s
created

TraitBlocoIX::calculateHeighBlokIX()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 17
ccs 0
cts 17
cp 0
crap 6
rs 9.7
c 0
b 0
f 0
1
<?php
2
3
namespace NFePHP\DA\NFe\Traits;
4
5
/**
6
 * Bloco Informações sobre impostos aproximados
7
 */
8
trait TraitBlocoIX
9
{
10
    protected function blocoIX($y)
11
    {
12
        $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...
Unused Code introduced by
$aFont 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...
13
        $valor = $this->getTagValue($this->ICMSTot, 'vTotTrib');
0 ignored issues
show
Bug introduced by
The property ICMSTot 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...
Bug introduced by
It seems like getTagValue() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
14
        $trib = !empty($valor) ? number_format((float) $valor, 2, ',', '.') : '-----';
15
        $texto = "Tributos totais Incidentes (Lei Federal 12.741/2012): R$ {$trib}";
16
        $aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => ''];
17
        $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...
18
            $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...
19
            $y,
20
            $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...
21
            $this->bloco9H,
0 ignored issues
show
Bug introduced by
The property bloco9H 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
            $texto,
23
            $aFont,
24
            'T',
25
            'C',
26
            false,
27
            '',
28
            true
29
        );
30
        if ($this->paperwidth < 70) {
0 ignored issues
show
Bug introduced by
The property paperwidth 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...
31
            $fsize = 5;
0 ignored issues
show
Unused Code introduced by
$fsize 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...
32
            $aFont = ['font'=> $this->fontePadrao, 'size' => 5, 'style' => ''];
33
        }
34
        $this->pdf->textBox(
35
            $this->margem,
36
            $y+3,
37
            $this->wPrint,
38
            $this->bloco9H-4,
39
            $this->infCpl,
0 ignored issues
show
Bug introduced by
The property infCpl 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...
40
            $aFont,
41
            'T',
42
            'L',
43
            false,
44
            '',
45
            false
46
        );
47
        return $this->bloco9H + $y;
48
    }
49
    
50
    /**
51
     * Calcula a altura do bloco IX
52
     * Depende do conteudo de infCpl
53
     *
54
     * @return int
55
     */
56
    protected function calculateHeighBlokIX()
57
    {
58
        $papel = [$this->paperwidth, 100];
59
        $wprint = $this->paperwidth - (2 * $this->margem);
60
        $logoAlign = 'L';
0 ignored issues
show
Unused Code introduced by
$logoAlign 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...
61
        $orientacao = 'P';
62
        $pdf = new \NFePHP\DA\Legacy\Pdf($orientacao, 'mm', $papel);
0 ignored issues
show
Documentation introduced by
$papel is of type array<integer,?,{"0":"?","1":"integer"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
63
        $fsize = 7;
64
        $aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => ''];
65
        if ($this->paperwidth < 70) {
66
            $fsize = 5;
67
            $aFont = ['font'=> $this->fontePadrao, 'size' => 5, 'style' => ''];
68
        }
69
        $hfont = (imagefontheight($fsize)/72)*13;
70
        $numlinhas = $pdf->getNumLines($this->infCpl, $wprint, $aFont);
71
        return (int) ($numlinhas * $hfont) + 2;
72
    }
73
}
74