Passed
Push — master ( f8305a...b6c7f7 )
by Roberto
03:01 queued 11s
created

Danfce::__construct()   B

Complexity

Conditions 7
Paths 48

Size

Total Lines 46

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 56

Importance

Changes 0
Metric Value
cc 7
nc 48
nop 1
dl 0
loc 46
ccs 0
cts 39
cp 0
crap 56
rs 8.2448
c 0
b 0
f 0
1
<?php
2
3
namespace NFePHP\DA\NFe;
4
5
/**
6
 * Classe para a impressão em PDF do Documento Auxiliar de NFe Consumidor
7
 * NOTA: Esta classe não é a indicada para quem faz uso de impressoras térmicas ESCPOS
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @copyright 2009-2019 NFePHP
12
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
13
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
14
 * @author    Roberto Spadim <roberto at spadim dot com dot br>
15
 */
16
use Exception;
17
use InvalidArgumentException;
18
use NFePHP\DA\Legacy\Dom;
19
use NFePHP\DA\Legacy\Pdf;
20
use NFePHP\DA\Common\DaCommon;
21
use Com\Tecnick\Barcode\Barcode;
22
use DateTime;
23
24
class Danfce extends DaCommon
25
{
26
    protected $papel;
27
    protected $paperwidth = 80;
28
    protected $creditos;
29
    protected $xml; // string XML NFe
30
    protected $logomarca=''; // path para logomarca em jpg
31
    protected $formatoChave="#### #### #### #### #### #### #### #### #### #### ####";
32
    protected $tpImp; //ambiente
33
    protected $fontePadrao='Times';
34
    protected $nfeProc;
35
    protected $nfe;
36
    protected $infNFe;
37
    protected $ide;
38
    protected $enderDest;
39
    protected $ICMSTot;
40
    protected $imposto;
41
    protected $emit;
42
    protected $enderEmit;
43
    protected $qrCode;
44
    protected $urlChave;
45
    protected $det;
46
    protected $infAdic;
47
    protected $textoAdic;
48
    protected $tpEmis;
49
    protected $pag;
50
    protected $vTroco;
51
    protected $dest;
52
    protected $imgQRCode;
53
    protected $urlQR = '';
54
    protected $pdf;
55
    protected $margemInterna = 2;
56
    protected $hMaxLinha = 9;
57
    protected $hBoxLinha = 6;
58
    protected $hLinha = 3;
59
  
60
    /**
61
     * __contruct
62
     *
63
     * @param string $docXML
64
     */
65
    public function __construct(
66
        $docXML = ''
67
    ) {
68
        
69
        $this->xml = $docXML;
70
        
71
        $this->fontePadrao = empty($fonteDANFE) ? 'Times' : $fonteDANFE;
0 ignored issues
show
Bug introduced by
The variable $fonteDANFE seems to never exist, and therefore empty should always return true. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
72
        $this->aFontTit = array('font' => $this->fontePadrao, 'size' => 9, 'style' => 'B');
0 ignored issues
show
Bug introduced by
The property aFontTit 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...
73
        $this->aFontTex = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
0 ignored issues
show
Bug introduced by
The property aFontTex 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...
74
        
75
        if (!empty($this->xml)) {
76
            $this->dom = new Dom();
0 ignored issues
show
Bug introduced by
The property dom 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...
77
            $this->dom->loadXML($this->xml);
78
            $this->nfeProc = $this->dom->getElementsByTagName("nfeProc")->item(0);
79
            $this->nfe = $this->dom->getElementsByTagName("NFe")->item(0);
80
            $this->infNFe = $this->dom->getElementsByTagName("infNFe")->item(0);
81
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
82
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
83
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
84
            $this->det = $this->dom->getElementsByTagName("det");
85
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
86
            $this->imposto = $this->dom->getElementsByTagName("imposto")->item(0);
87
            $this->ICMSTot = $this->dom->getElementsByTagName("ICMSTot")->item(0);
88
            $this->tpImp = $this->ide->getElementsByTagName("tpImp")->item(0)->nodeValue;
89
            $this->infAdic = $this->dom->getElementsByTagName("infAdic")->item(0);
90
            $this->tpEmis = $this->dom->getValue($this->ide, "tpEmis");
0 ignored issues
show
Documentation introduced by
$this->ide is of type object<DOMNode>, but the function expects a object<NFePHP\DA\Legacy\DOMElement>.

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...
91
            
92
            //se for o layout 4.0 busca pelas tags de detalhe do pagamento
93
            //senao, busca pelas tags de pagamento principal
94
            if ($this->infNFe->getAttribute("versao") == "4.00") {
95
                $this->pag = $this->dom->getElementsByTagName("detPag");
96
                
97
                $tagPag = $this->dom->getElementsByTagName("pag")->item(0);
98
                $this->vTroco = $this->getTagValue($tagPag, "vTroco");
99
            } else {
100
                $this->pag = $this->dom->getElementsByTagName("pag");
101
            }
102
        }
103
        $this->qrCode = !empty($this->dom->getElementsByTagName('qrCode')->item(0)->nodeValue)
104
            ? $this->dom->getElementsByTagName('qrCode')->item(0)->nodeValue : null;
105
        $this->urlChave = !empty($this->dom->getElementsByTagName('urlChave')->item(0)->nodeValue)
106
            ? $this->dom->getElementsByTagName('urlChave')->item(0)->nodeValue : null;
107
        if ($this->getTagValue($this->ide, "mod") != '65') {
108
            throw new InvalidArgumentException("O xml do DANFE deve ser uma NFC-e modelo 65");
109
        }
110
    }
111
    
112
    /**
113
     * Add the credits to the integrator in the footer message
114
     * @param string $message
115
     */
116
    public function creditsIntegratorFooter($message = '')
117
    {
118
        $this->creditos = trim($message);
119
    }
120
    
121
    /**
122
     * Dados brutos do PDF
123
     * @return string
124
     */
125
    public function render(
126
        $logo = '',
127
        $orientacao = 'P',
128
        $papel = 'A4',
0 ignored issues
show
Unused Code introduced by
The parameter $papel is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
129
        $logoAlign = 'C',
130
        $depecNumReg = ''
131
    ) {
132
        if (empty($this->pdf)) {
133
            $this->monta($logo, $depecNumReg, $logoAlign);
134
        }
135
        return $this->pdf->getPdf();
136
    }
137
    
138
    public function paperWidth($width = 80)
139
    {
140
        if (is_int($width) && $width > 60) {
141
            $this->paperwidth = $width;
142
        }
143
        return $this->paperwidth;
144
    }
145
    
146
    public function monta(
147
        $logo = '',
148
        $depecNumReg = '',
149
        $logoAlign = 'C'
150
    ) {
151
        $this->logomarca = $this->adjustImage($logo, true);
152
        $qtdItens = $this->det->length;
153
        $qtdPgto = $this->pag->length;
154
        $hMaxLinha = $this->hMaxLinha;
155
        $hBoxLinha = $this->hBoxLinha;
0 ignored issues
show
Unused Code introduced by
$hBoxLinha 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...
156
        $hLinha = $this->hLinha;
157
        $tamPapelVert = 160 + 16 + 12 + (($qtdItens - 1) * $hMaxLinha) + ($qtdPgto * $hLinha);
158
        // verifica se existe informações adicionais
159
        $this->textoAdic = '';
160
        if (isset($this->infAdic)) {
161
            $this->textoAdic .= !empty($this->infAdic->getElementsByTagName('infCpl')->item(0)->nodeValue) ?
162
            'Inf. Contribuinte: '.
163
            trim($this->anfaveaDANFE($this->infAdic->getElementsByTagName('infCpl')->item(0)->nodeValue)) : '';
164
            if (!empty($this->textoAdic)) {
165
                $this->textoAdic = str_replace(";", "\n", $this->textoAdic);
166
                $alinhas = explode("\n", $this->textoAdic);
167
                $numlinhasdados = 0;
168
                $tempPDF = new Pdf(); // cria uma instancia temporaria da class pdf
169
                $tempPDF->setFont('times', '', '8'); // seta a font do PDF
170
                foreach ($alinhas as $linha) {
171
                    $linha = trim($linha);
172
                    $numlinhasdados += $tempPDF->wordWrap($linha, 76 - 0.2);
0 ignored issues
show
Documentation introduced by
$linha is of type string, but the function expects a object<NFePHP\DA\Legacy\type>.

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...
Documentation introduced by
76 - 0.2 is of type double, but the function expects a object<NFePHP\DA\Legacy\type>.

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...
173
                }
174
                $hdadosadic = round(($numlinhasdados + 1) * $tempPDF->fontSize, 0);
175
                if ($hdadosadic < 5) {
176
                    $hdadosadic = 5;
177
                }
178
                // seta o tamanho do papel
179
                $tamPapelVert += $hdadosadic;
180
            }
181
        }
182
        $this->orientacao = 'P';
183
        $this->papel = [$this->paperwidth, $tamPapelVert];
184
        $this->logoAlign = $logoAlign;
0 ignored issues
show
Bug introduced by
The property logoAlign 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...
185
        //$this->situacao_externa = $situacaoExterna;
186
        $this->numero_registro_dpec = $depecNumReg;
0 ignored issues
show
Bug introduced by
The property numero_registro_dpec 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...
187
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
0 ignored issues
show
Documentation introduced by
$this->papel is of type array<integer,integer|do...,"1":"double|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...
188
        
189
        //margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à
190
        //margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui
191
        //apenas para controle se necessário ser maior do que a margem superior
192
        $margSup = 2;
193
        $margEsq = 2;
194
        $margInf = 2;
195
        // posição inicial do conteúdo, a partir do canto superior esquerdo da página
196
        $xInic = $margEsq;
197
        $yInic = $margSup;
198
        $maxW = 80;
199
        $maxH = $tamPapelVert;
200
        //total inicial de paginas
201
        $totPag = 1;
0 ignored issues
show
Unused Code introduced by
$totPag 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...
202
        //largura imprimivel em mm: largura da folha menos as margens esq/direita
203
        $this->wPrint = $maxW-($margEsq*2);
204
        //comprimento (altura) imprimivel em mm: altura da folha menos as margens
205
        //superior e inferior
206
        $this->hPrint = $maxH-$margSup-$margInf;
207
        // estabelece contagem de paginas
208
        $this->pdf->aliasNbPages();
209
        $this->pdf->setMargins($margEsq, $margSup); // fixa as margens
210
        $this->pdf->setDrawColor(0, 0, 0);
211
        $this->pdf->setFillColor(255, 255, 255);
212
        $this->pdf->open(); // inicia o documento
213
        $this->pdf->addPage($this->orientacao, $this->papel); // adiciona a primeira página
0 ignored issues
show
Documentation introduced by
$this->papel is of type array<integer,integer|do...,"1":"double|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...
214
        $this->pdf->setLineWidth(0.1); // define a largura da linha
215
        $this->pdf->setTextColor(0, 0, 0);
216
        $this->pdf->textBox(0, 0, $maxW, $maxH); // POR QUE PRECISO DESA LINHA?
217
        $hcabecalho = 27;//para cabeçalho (dados emitente mais logomarca)  (FIXO)
218
        $hcabecalhoSecundario = 10 + 3;//para cabeçalho secundário (cabeçalho sefaz) (FIXO)
219
        $hprodutos = $hLinha + ($qtdItens * $hMaxLinha) ;//box poduto
220
        $hTotal = 12; //box total (FIXO)
221
        $hpagamentos = $hLinha + ($qtdPgto * $hLinha) + 3;//para pagamentos
222
        if (!empty($this->vTroco)) {
223
            $hpagamentos += $hLinha;
224
        }
225
                
226
        $hmsgfiscal = 21 + 2; // para imposto (FIXO)
227
        $hcliente = !isset($this->dest) ? 6 : 12; // para cliente (FIXO)
228
        $hcontingencia = $this->tpEmis == 9 ? 6 : 0; // para contingência (FIXO)
0 ignored issues
show
Unused Code introduced by
$hcontingencia 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...
229
        $hQRCode = 50; // para qrcode (FIXO)
230
        $hCabecItens = 4; //cabeçalho dos itens
231
        
232
        $hUsado = $hCabecItens;
0 ignored issues
show
Unused Code introduced by
$hUsado 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...
233
        $w2 = round($this->wPrint * 0.31, 0);
0 ignored issues
show
Unused Code introduced by
$w2 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...
234
        $totPag = 1;
235
        $pag = 1;
236
        $x = $xInic;
237
        //COLOCA CABEÇALHO
238
        $y = $yInic;
239
        $y = $this->cabecalhoDANFE($x, $y, $hcabecalho, $pag, $totPag);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->cabecalhoDANFE($x...becalho, $pag, $totPag) (which targets NFePHP\DA\NFe\Danfce::cabecalhoDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y 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...
240
        //COLOCA CABEÇALHO SECUNDÁRIO
241
        $y = $hcabecalho;
242
        $y = $this->cabecalhoSecundarioDANFE($x, $y, $hcabecalhoSecundario);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->cabecalhoSecundar... $hcabecalhoSecundario) (which targets NFePHP\DA\NFe\Danfce::cabecalhoSecundarioDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y 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...
243
        $jj = $hcabecalho + $hcabecalhoSecundario;
0 ignored issues
show
Unused Code introduced by
$jj 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...
244
        //COLOCA PRODUTOS
245
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario;
246
        $y = $this->produtosDANFE($x, $y, $hprodutos);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->produtosDANFE($x, $y, $hprodutos) (which targets NFePHP\DA\NFe\Danfce::produtosDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y 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...
247
        //COLOCA TOTAL
248
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos;
249
        $y = $this->totalDANFE($x, $y, $hTotal);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->totalDANFE($x, $y, $hTotal) (which targets NFePHP\DA\NFe\Danfce::totalDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y 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...
250
        //COLOCA PAGAMENTOS
251
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal;
252
        $y = $this->pagamentosDANFE($x, $y, $hpagamentos);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pagamentosDANFE($x, $y, $hpagamentos) (which targets NFePHP\DA\NFe\Danfce::pagamentosDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y 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...
253
        //COLOCA MENSAGEM FISCAL
254
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal+ $hpagamentos;
255
        $y = $this->fiscalDANFE($x, $y, $hmsgfiscal);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->fiscalDANFE($x, $y, $hmsgfiscal) (which targets NFePHP\DA\NFe\Danfce::fiscalDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y 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...
256
        //COLOCA CONSUMIDOR
257
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal + $hpagamentos + $hmsgfiscal;
258
        $y = $this->consumidorDANFE($x, $y, $hcliente);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->consumidorDANFE($x, $y, $hcliente) (which targets NFePHP\DA\NFe\Danfce::consumidorDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y 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...
259
        //COLOCA QRCODE
260
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos
261
            + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente;
262
        $y = $this->qrCodeDANFE($x, $y, $hQRCode);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->qrCodeDANFE($x, $y, $hQRCode) (which targets NFePHP\DA\NFe\Danfce::qrCodeDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y 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...
263
        
264
        //adiciona as informações opcionais
265
        if (!empty($this->textoAdic)) {
266
            $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos
267
            + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente + $hQRCode;
268
            $hInfAdic = 0;
269
            $y = $this->infAdic($x, $y, $hInfAdic);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->infAdic($x, $y, $hInfAdic) (which targets NFePHP\DA\NFe\Danfce::infAdic()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y 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...
270
        }
271
    }
272
    
273
    protected function cabecalhoDANFE($x = 0, $y = 0, $h = 0, $pag = '1', $totPag = '1')
0 ignored issues
show
Unused Code introduced by
The parameter $x is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $pag is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $totPag is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
274
    {
275
        $emitRazao  = $this->getTagValue($this->emit, "xNome");
276
        $emitCnpj   = $this->getTagValue($this->emit, "CNPJ");
277
        $emitCnpj   = $this->formatField($emitCnpj, "##.###.###/####-##");
278
        $emitIE     = $this->getTagValue($this->emit, "IE");
279
        $emitIM     = $this->getTagValue($this->emit, "IM");
280
        $emitFone = $this->getTagValue($this->enderEmit, "fone");
281
        $foneLen = strlen($emitFone);
282
        if ($foneLen>0) {
283
            $ddd = substr($emitFone, 0, 2);
284
            $fone1 = substr($emitFone, -8);
285
            $digito9 = ' ';
286
            if ($foneLen == 11) {
287
                $digito9 = substr($emitFone, 2, 1);
288
            }
289
            $emitFone = ' - ('.$ddd.') '.$digito9. ' ' . substr($fone1, 0, 4) . '-' . substr($fone1, -4);
290
        } else {
291
            $emitFone = '';
292
        }
293
        $emitLgr = $this->getTagValue($this->enderEmit, "xLgr");
294
        $emitNro = $this->getTagValue($this->enderEmit, "nro");
295
        $emitCpl = $this->getTagValue($this->enderEmit, "xCpl", "");
296
        $emitBairro = $this->getTagValue($this->enderEmit, "xBairro");
297
        $emitCEP = $this->formatField($this->getTagValue($this->enderEmit, "CEP"), "#####-###");
298
        $emitMun = $this->getTagValue($this->enderEmit, "xMun");
299
        $emitUF = $this->getTagValue($this->enderEmit, "UF");
300
        // CONFIGURAÇÃO DE POSIÇÃO
301
        $margemInterna = $this->margemInterna;
302
        $maxW = $this->wPrint;
303
        $h = $h-($margemInterna);
304
        //COLOCA LOGOMARCA
305
        if (!empty($this->logomarca)) {
306
            $xImg = $margemInterna;
307
            $yImg = $margemInterna + 1;
0 ignored issues
show
Unused Code introduced by
$yImg 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...
308
            $logoInfo = getimagesize($this->logomarca);
309
            $logoWmm = ($logoInfo[0]/72)*25.4;
310
            $logoHmm = ($logoInfo[1]/72)*25.4;
311
            $nImgW = 30;
312
            $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
313
            $yImg = $margemInterna + $nImgH/2;
314
            $this->pdf->image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
315
            $xRs = ($maxW*0.4) + $margemInterna;
316
            $wRs = ($maxW*0.6);
317
            $alignEmit = 'L';
318
        } else {
319
            $xRs = $margemInterna;
320
            $wRs = ($maxW*1);
321
            $alignEmit = 'L';
322
        }
323
        //COLOCA RAZÃO SOCIAL
324
        $texto = $emitRazao;
325
        $texto = $texto . "\nCNPJ:" . $emitCnpj;
326
        $texto = $texto . "\nIE:" . $emitIE;
327
        if (!empty($emitIM)) {
328
            $texto = $texto . " - IM:" . $emitIM;
329
        }
330
        $texto = $texto . "\n" . $emitLgr . "," . $emitNro . " " . $emitCpl . "," . $emitBairro
331
                . ". CEP:" . $emitCEP . ". " . $emitMun . "-" . $emitUF . $emitFone;
332
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
333
        $this->pdf->textBox($xRs, $y, $wRs, $h, $texto, $aFont, 'C', $alignEmit, 0, '', false);
334
    }
335
    
336
    protected function cabecalhoSecundarioDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
337
    {
338
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
339
        $maxW = $this->wPrint;
340
        $w = ($maxW*1);
341
        $hBox1 = 7;
342
        $texto = "DANFE NFC-e\nDocumento Auxiliar da Nota Fiscal de Consumidor Eletrônica";
343
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
344
        $this->pdf->textBox($x, $y, $w, $hBox1, $texto, $aFont, 'C', 'C', 0, '', false);
345
        $hBox2 = 4;
346
        $yBox2 = $y + $hBox1;
347
        $texto = "\nNFC-e não permite aproveitamento de crédito de ICMS";
348
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
349
        $this->pdf->textBox($x, $yBox2, $w, $hBox2, $texto, $aFont, 'C', 'C', 0, '', false);
350
    }
351
    
352
    protected function produtosDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
353
    {
354
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
355
        $maxW = $this->wPrint;
356
        $qtdItens = $this->det->length;
357
        $w = ($maxW*1);
358
        $hLinha = $this->hLinha;
359
        $aFontCabProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
360
        $wBoxCod = $w*0.17;
361
        $texto = "CÓDIGO";
362
        $this->pdf->textBox($x, $y, $wBoxCod, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
363
        $wBoxDescricao = $w*0.43;
364
        $xBoxDescricao = $wBoxCod + $x;
365
        $texto = "DESCRICÃO";
366
        $this->pdf->textBox(
367
            $xBoxDescricao,
368
            $y,
369
            $wBoxDescricao,
370
            $hLinha,
371
            $texto,
372
            $aFontCabProdutos,
373
            'T',
374
            'L',
375
            0,
376
            '',
377
            false
378
        );
379
        $wBoxQt = $w*0.08;
380
        $xBoxQt = $wBoxDescricao + $xBoxDescricao;
381
        $texto = "QT";
382
        $this->pdf->textBox($xBoxQt, $y, $wBoxQt, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
383
        $wBoxUn = $w*0.06;
384
        $xBoxUn = $wBoxQt + $xBoxQt;
385
        $texto = "UN";
386
        $this->pdf->textBox($xBoxUn, $y, $wBoxUn, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
387
        $wBoxVl = $w*0.13;
388
        $xBoxVl = $wBoxUn + $xBoxUn;
389
        $texto = "VALOR";
390
        $this->pdf->textBox($xBoxVl, $y, $wBoxVl, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
391
        $wBoxTotal = $w*0.13;
392
        $xBoxTotal = $wBoxVl + $xBoxVl;
393
        $texto = "TOTAL";
394
        $this->pdf->textBox($xBoxTotal, $y, $wBoxTotal, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
395
        $hBoxLinha = $this->hBoxLinha;
0 ignored issues
show
Unused Code introduced by
$hBoxLinha 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...
396
        $hMaxLinha = $this->hMaxLinha;
397
        $cont = 0;
398
        $aFontProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
399
        if ($qtdItens > 0) {
400
            foreach ($this->det as $detI) {
401
                $thisItem   = $detI;
402
                $prod       = $thisItem->getElementsByTagName("prod")->item(0);
403
                $nitem      = $thisItem->getAttribute("nItem");
0 ignored issues
show
Unused Code introduced by
$nitem 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...
404
                $cProd      = $this->getTagValue($prod, "cProd");
405
                $xProd      = $this->getTagValue($prod, "xProd");
406
                $qCom       = number_format($this->getTagValue($prod, "qCom"), 2, ",", ".");
407
                $uCom       = $this->getTagValue($prod, "uCom");
408
                $vUnCom     = number_format($this->getTagValue($prod, "vUnCom"), 2, ",", ".");
409
                $vProd      = number_format($this->getTagValue($prod, "vProd"), 2, ",", ".");
410
                //COLOCA PRODUTO
411
                $yBoxProd = $y + $hLinha + ($cont*$hMaxLinha);
412
                //COLOCA PRODUTO CÓDIGO
413
                $wBoxCod = $w*0.17;
414
                $texto = $cProd;
415
                $this->pdf->textBox(
416
                    $x,
417
                    $yBoxProd,
418
                    $wBoxCod,
419
                    $hMaxLinha,
420
                    $texto,
421
                    $aFontProdutos,
422
                    'C',
423
                    'C',
424
                    0,
425
                    '',
426
                    false
427
                );
428
                //COLOCA PRODUTO DESCRIÇÃO
429
                $wBoxDescricao = $w*0.43;
430
                $xBoxDescricao = $wBoxCod + $x;
431
                $texto = $xProd;
432
                $this->pdf->textBox(
433
                    $xBoxDescricao,
434
                    $yBoxProd,
435
                    $wBoxDescricao,
436
                    $hMaxLinha,
437
                    $texto,
438
                    $aFontProdutos,
439
                    'C',
440
                    'L',
441
                    0,
442
                    '',
443
                    false
444
                );
445
                //COLOCA PRODUTO QUANTIDADE
446
                $wBoxQt = $w*0.08;
447
                $xBoxQt = $wBoxDescricao + $xBoxDescricao;
448
                $texto = $qCom;
449
                $this->pdf->textBox(
450
                    $xBoxQt,
451
                    $yBoxProd,
452
                    $wBoxQt,
453
                    $hMaxLinha,
454
                    $texto,
455
                    $aFontProdutos,
456
                    'C',
457
                    'C',
458
                    0,
459
                    '',
460
                    false
461
                );
462
                //COLOCA PRODUTO UNIDADE
463
                $wBoxUn = $w*0.06;
464
                $xBoxUn = $wBoxQt + $xBoxQt;
465
                $texto = $uCom;
466
                $this->pdf->textBox(
467
                    $xBoxUn,
468
                    $yBoxProd,
469
                    $wBoxUn,
470
                    $hMaxLinha,
471
                    $texto,
472
                    $aFontProdutos,
473
                    'C',
474
                    'C',
475
                    0,
476
                    '',
477
                    false
478
                );
479
                //COLOCA PRODUTO VL UNITÁRIO
480
                $wBoxVl = $w*0.13;
481
                $xBoxVl = $wBoxUn + $xBoxUn;
482
                $texto = $vUnCom;
483
                $this->pdf->textBox(
484
                    $xBoxVl,
485
                    $yBoxProd,
486
                    $wBoxVl,
487
                    $hMaxLinha,
488
                    $texto,
489
                    $aFontProdutos,
490
                    'C',
491
                    'R',
492
                    0,
493
                    '',
494
                    false
495
                );
496
                //COLOCA PRODUTO VL TOTAL
497
                $wBoxTotal = $w*0.13;
498
                $xBoxTotal = $wBoxVl + $xBoxVl;
499
                $texto = $vProd;
500
                $this->pdf->textBox(
501
                    $xBoxTotal,
502
                    $yBoxProd,
503
                    $wBoxTotal,
504
                    $hMaxLinha,
505
                    $texto,
506
                    $aFontProdutos,
507
                    'C',
508
                    'R',
509
                    0,
510
                    '',
511
                    false
512
                );
513
                
514
                $cont++;
515
            }
516
        }
517
    }
518
    
519
    protected function totalDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
520
    {
521
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
522
        $maxW = $this->wPrint;
523
        $hLinha = 3;
524
        $wColEsq = ($maxW*0.7);
525
        $wColDir = ($maxW*0.3);
526
        $xValor = $x + $wColEsq;
527
        $qtdItens = $this->det->length;
528
        $vProd = $this->getTagValue($this->ICMSTot, "vProd");
529
        $vNF = $this->getTagValue($this->ICMSTot, "vNF");
530
        $vDesc  = $this->getTagValue($this->ICMSTot, "vDesc");
531
        $vFrete = $this->getTagValue($this->ICMSTot, "vFrete");
532
        $vTotTrib = $this->getTagValue($this->ICMSTot, "vTotTrib");
533
        $texto = "Qtd. Total de Itens";
534
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
535
        $this->pdf->textBox($x, $y, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
536
        $texto = $qtdItens;
537
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
538
        $this->pdf->textBox($xValor, $y, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
539
        $yTotal = $y + ($hLinha);
540
        $texto = "Total de Produtos";
541
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
542
        $this->pdf->textBox($x, $yTotal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
543
        $texto = "R$ " . number_format($vProd, 2, ",", ".");
544
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
545
        $this->pdf->textBox($xValor, $yTotal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
546
        $yDesconto = $y + ($hLinha*2);
547
        $texto = "Descontos";
548
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
549
        $this->pdf->textBox($x, $yDesconto, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
550
        $texto = "R$ " . $vDesc;
551
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
552
        $this->pdf->textBox($xValor, $yDesconto, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
553
        $yFrete= $y + ($hLinha*3);
554
        $texto = "Frete";
555
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
556
        $this->pdf->textBox($x, $yFrete, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
557
        $texto = "R$ " . $vFrete;
558
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
559
        $this->pdf->textBox($xValor, $yFrete, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
560
        $yTotalFinal = $y + ($hLinha*4);
561
        $texto = "Total";
562
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
563
        $this->pdf->textBox($x, $yTotalFinal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
564
        $texto = "R$ " . $vNF;
565
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
566
        $this->pdf->textBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
567
        $yTotalFinal = $y + ($hLinha*5);
568
        $texto = "Informação dos Tributos Totais Incidentes";
569
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>''];
570
        $this->pdf->textBox($x, $yTotalFinal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
571
        $texto = "R$ " . $vTotTrib;
572
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
573
        $this->pdf->textBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
574
    }
575
    
576
    protected function pagamentosDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
577
    {
578
        $y += 6;
579
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
580
        $maxW = $this->wPrint;
581
        $qtdPgto = $this->pag->length;
582
        $w = ($maxW*1);
583
        $hLinha = $this->hLinha;
584
        $wColEsq = ($maxW*0.7);
585
        $wColDir = ($maxW*0.3);
0 ignored issues
show
Unused Code introduced by
$wColDir 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...
586
        $xValor = $x + $wColEsq;
0 ignored issues
show
Unused Code introduced by
$xValor 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...
587
        $aFontPgto = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
588
        $wBoxEsq = $w*0.7;
589
        $texto = "FORMA DE PAGAMENTO";
590
        $this->pdf->textBox($x, $y, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
591
        $wBoxDir = $w*0.3;
592
        $xBoxDescricao = $x + $wBoxEsq;
593
        $texto = "VALOR PAGO";
594
        $this->pdf->textBox($xBoxDescricao, $y, $wBoxDir, $hLinha, $texto, $aFontPgto, 'T', 'R', 0, '', false);
595
        $cont = 0;
596
        if ($qtdPgto > 0) {
597
            foreach ($this->pag as $pagI) {
598
                $tPag = $this->getTagValue($pagI, "tPag");
599
                $tPagNome = $this->tipoPag($tPag);
600
                $tPnome = $tPagNome;
0 ignored issues
show
Unused Code introduced by
$tPnome 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...
601
                $vPag = number_format($this->getTagValue($pagI, "vPag"), 2, ",", ".");
602
                $card = $pagI->getElementsByTagName("card")->item(0);
603
                $cardCNPJ = '';
0 ignored issues
show
Unused Code introduced by
$cardCNPJ 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...
604
                $tBand = '';
0 ignored issues
show
Unused Code introduced by
$tBand 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...
605
                $tBandNome = '';
0 ignored issues
show
Unused Code introduced by
$tBandNome 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...
606
                if (isset($card)) {
607
                    $cardCNPJ = $this->getTagValue($card, "CNPJ");
0 ignored issues
show
Unused Code introduced by
$cardCNPJ 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...
608
                    $tBand    = $this->getTagValue($card, "tBand");
609
                    $cAut = $this->getTagValue($card, "cAut");
0 ignored issues
show
Unused Code introduced by
$cAut 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...
610
                    $tBandNome = self::getCardName($tBand);
0 ignored issues
show
Unused Code introduced by
$tBandNome 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...
611
                }
612
                //COLOCA PRODUTO
613
                $yBoxProd = $y + $hLinha + ($cont*$hLinha);
614
                //COLOCA PRODUTO CÓDIGO
615
                $texto = $tPagNome;
616
                $this->pdf->textBox($x, $yBoxProd, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
617
                //COLOCA PRODUTO DESCRIÇÃO
618
                $xBoxDescricao = $wBoxEsq + $x;
619
                $texto = "R$ " . $vPag;
620
                $this->pdf->textBox(
621
                    $xBoxDescricao,
622
                    $yBoxProd,
623
                    $wBoxDir,
624
                    $hLinha,
625
                    $texto,
626
                    $aFontPgto,
627
                    'C',
628
                    'R',
629
                    0,
630
                    '',
631
                    false
632
                );
633
                $cont++;
634
            }
635
            
636
            if (!empty($this->vTroco)) {
637
                $yBoxProd = $y + $hLinha + ($cont*$hLinha);
638
                //COLOCA PRODUTO CÓDIGO
639
                $texto = 'Troco';
640
                $this->pdf->textBox($x, $yBoxProd, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
641
                //COLOCA PRODUTO DESCRIÇÃO
642
                $xBoxDescricao = $wBoxEsq + $x;
643
                $texto = "R$ " . number_format($this->vTroco, 2, ",", ".");
644
                $this->pdf->textBox(
645
                    $xBoxDescricao,
646
                    $yBoxProd,
647
                    $wBoxDir,
648
                    $hLinha,
649
                    $texto,
650
                    $aFontPgto,
651
                    'C',
652
                    'R',
653
                    0,
654
                    '',
655
                    false
656
                );
657
            }
658
        }
659
    }
660
    
661
    protected function fiscalDANFE($x = 0, $y = 0, $h = 0)
662
    {
663
        $y += 6;
664
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
665
        $maxW = $this->wPrint;
666
        $w = ($maxW*1);
667
        $hLinha = $this->hLinha;
668
        $aFontTit = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'];
669
        $aFontTex = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>''];
670
        $digVal = $this->getTagValue($this->nfe, "DigestValue");
0 ignored issues
show
Unused Code introduced by
$digVal 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...
671
        $chNFe = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
672
        $tpAmb = $this->getTagValue($this->ide, 'tpAmb');
0 ignored issues
show
Unused Code introduced by
$tpAmb 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...
673
        
674
        if ($this->checkCancelada()) {
675
            //101 Cancelamento
676
            $this->pdf->setTextColor(255, 0, 0);
677
            $texto = "NFCe CANCELADA";
678
            $this->pdf->textBox($x, $y - 25, $w, $h, $texto, $aFontTit, 'C', 'C', 0, '');
679
            $this->pdf->setTextColor(0, 0, 0);
680
        }
681
        
682
        if ($this->checkDenegada()) {
683
            //uso denegado
684
            $this->pdf->setTextColor(255, 0, 0);
685
            $texto = "NFCe CANCELADA";
686
            $this->pdf->textBox($x, $y - 25, $w, $h, $texto, $aFontTit, 'C', 'C', 0, '');
687
            $this->pdf->SetTextColor(0, 0, 0);
688
        }
689
        
690
        $cUF = $this->getTagValue($this->ide, 'cUF');
0 ignored issues
show
Unused Code introduced by
$cUF 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...
691
        $nNF = $this->getTagValue($this->ide, 'nNF');
692
        $serieNF = str_pad($this->getTagValue($this->ide, "serie"), 3, "0", STR_PAD_LEFT);
693
        $dhEmi = $this->getTagValue($this->ide, "dhEmi");
694
        $dhEmilocal = new \DateTime($dhEmi);
695
        $dhEmiLocalFormat = $dhEmilocal->format('d/m/Y H:i:s');
696
        $texto = "ÁREA DE MENSAGEM FISCAL";
697
        $this->pdf->textBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
698
        $yTex1 = $y + ($hLinha*1);
699
        $hTex1 = $hLinha*2;
700
        $texto = "Número " . $nNF . " Série " . $serieNF . " " .$dhEmiLocalFormat . " - Via Consumidor";
701
        $this->pdf->textBox($x, $yTex1, $w, $hTex1, $texto, $aFontTex, 'C', 'C', 0, '', false);
702
        $yTex2 = $y + ($hLinha*3);
703
        $hTex2 = $hLinha*2;
704
        
705
        $texto = !empty($this->urlChave) ? "Consulte pela Chave de Acesso em " . $this->urlChave : '';
706
        $this->pdf->textBox($x, $yTex2, $w, $hTex2, $texto, $aFontTex, 'C', 'C', 0, '', false);
707
        $texto = "CHAVE DE ACESSO";
708
        $yTit2 = $y + ($hLinha*5);
709
        $this->pdf->textBox($x, $yTit2, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
710
        $yTex3 = $y + ($hLinha*6);
711
        $texto = $chNFe;
712
        $this->pdf->textBox($x, $yTex3, $w, $hLinha, $texto, $aFontTex, 'C', 'C', 0, '', false);
713
    }
714
    
715
    protected function consumidorDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
716
    {
717
        $y += 6;
718
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
719
        $maxW = $this->wPrint;
720
        $w = ($maxW*1);
721
        $hLinha = $this->hLinha;
722
        $aFontTit = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'];
723
        $aFontTex = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>''];
724
        $texto = "CONSUMIDOR";
725
        $this->pdf->textBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
726
        if (isset($this->dest)) {
727
            $considEstrangeiro = !empty($this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue)
728
                    ? $this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue
729
                    : '';
730
            $consCPF = !empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
731
                    ? $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue
732
                    : '';
733
            $consCNPJ = !empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)
734
                    ? $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue
735
                    : '';
736
            $cDest = $consCPF.$consCNPJ.$considEstrangeiro; //documentos do consumidor
0 ignored issues
show
Unused Code introduced by
$cDest 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...
737
            $enderDest = $this->dest->getElementsByTagName("enderDest")->item(0);
738
            $consNome = $this->getTagValue($this->dest, "xNome");
739
            $consLgr = $this->getTagValue($enderDest, "xLgr");
740
            $consNro = $this->getTagValue($enderDest, "nro");
741
            $consCpl = $this->getTagValue($enderDest, "xCpl", " - ");
742
            $consBairro = $this->getTagValue($enderDest, "xBairro");
743
            $consCEP = $this->formatField($this->getTagValue($enderDest, "CEP"));
744
            $consMun = $this->getTagValue($enderDest, "xMun");
745
            $consUF = $this->getTagValue($enderDest, "UF");
746
            $considEstrangeiro = $this->getTagValue($this->dest, "idEstrangeiro");
747
            $consCPF = $this->getTagValue($this->dest, "CPF");
748
            $consCNPJ = $this->getTagValue($this->dest, "CNPJ");
749
            $consDoc = "";
750
            if (!empty($consCNPJ)) {
751
                $consDoc = "CNPJ: $consCNPJ";
752
            } elseif (!empty($consCPF)) {
753
                $consDoc = "CPF: $consCPF";
754
            } elseif (!empty($considEstrangeiro)) {
755
                $consDoc = "id: $considEstrangeiro";
756
            }
757
            $consEnd = "";
758
            if (!empty($consLgr)) {
759
                $consEnd = $consLgr
760
                    . ","
761
                    . $consNro
762
                    . " "
763
                    . $consCpl
764
                    . ","
765
                    . $consBairro
766
                    . ". CEP:"
767
                    . $consCEP
768
                    . ". "
769
                    . $consMun
770
                    . "-"
771
                    . $consUF;
772
            }
773
            $yTex1 = $y + $hLinha;
774
            $texto = $consNome;
775
            if (!empty($consDoc)) {
776
                $texto .= " - ". $consDoc . "\n" . $consEnd;
777
                $this->pdf->textBox($x, $yTex1, $w, $hLinha*3, $texto, $aFontTex, 'C', 'C', 0, '', false);
778
            }
779
        } else {
780
            $yTex1 = $y + $hLinha;
781
            $texto = "Consumidor não identificado";
782
            $this->pdf->textBox($x, $yTex1, $w, $hLinha, $texto, $aFontTex, 'C', 'C', 0, '', false);
783
        }
784
    }
785
    
786
    protected function qrCodeDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
787
    {
788
        $y += 6;
789
        $margemInterna = $this->margemInterna;
790
        $maxW = $this->wPrint;
791
        $w = ($maxW*1)+4;
792
        $hLinha = $this->hLinha;
0 ignored issues
show
Unused Code introduced by
$hLinha 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...
793
        $hBoxLinha = $this->hBoxLinha;
794
        $aFontTit = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
0 ignored issues
show
Unused Code introduced by
$aFontTit 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...
795
        $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
796
        $dhRecbto = '';
797
        $nProt = '';
798
        if (isset($this->nfeProc)) {
799
            $nProt = $this->getTagValue($this->nfeProc, "nProt");
800
            $dhRecbto  = $this->getTagValue($this->nfeProc, "dhRecbto");
801
        }
802
        $barcode = new Barcode();
803
        $bobj = $barcode->getBarcodeObj(
804
            'QRCODE,M',
805
            $this->qrCode,
806
            -4,
807
            -4,
808
            'black',
809
            array(-2, -2, -2, -2)
810
        )->setBackgroundColor('white');
811
        $qrcode = $bobj->getPngData();
812
        $wQr = 50;
813
        $hQr = 50;
814
        $yQr = ($y+$margemInterna);
815
        $xQr = ($w/2) - ($wQr/2);
816
        // prepare a base64 encoded "data url"
817
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
818
        $info = getimagesize($pic);
0 ignored issues
show
Unused Code introduced by
$info 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...
819
        $this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG');
820
        $dt = new DateTime($dhRecbto);
821
        $yQr = ($yQr+$hQr+$margemInterna);
822
        $this->pdf->textBox($x, $yQr, $w-4, $hBoxLinha, "Protocolo de Autorização: " . $nProt . "\n"
823
            . $dt->format('d/m/Y H:i:s'), $aFontTex, 'C', 'C', 0, '', false);
824
    }
825
   
826
    protected function infAdic($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
827
    {
828
        $y += 17;
829
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
830
        $maxW = $this->wPrint;
831
        $w = ($maxW * 1);
832
        $hLinha = $this->hLinha;
833
        $aFontTit = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
834
        $aFontTex = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
835
        // seta o textbox do titulo
836
        $texto = "INFORMAÇÃO ADICIONAL";
837
        if (isset($this->nfeProc) && $this->nfeProc->getElementsByTagName("xMsg")->length) {
838
            $y += 3;
839
            $texto = $texto . ' ' . $this->nfeProc->getElementsByTagName("xMsg")->item(0)->nodeValue;
840
            $heigthText = $this->pdf->textBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
0 ignored issues
show
Unused Code introduced by
$heigthText 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...
841
            $y += 4;
842
        } else {
843
            $heigthText = $this->pdf->textBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
0 ignored issues
show
Unused Code introduced by
$heigthText 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...
844
        }
845
        // seta o textbox do texto adicional
846
        $this->pdf->textBox($x, $y+3, $w-2, $hLinha-3, $this->textoAdic, $aFontTex, 'T', 'L', 0, '', false);
847
    }
848
    
849
    /**
850
     * anfavea
851
     * Função para transformar o campo cdata do padrão ANFAVEA para
852
     * texto imprimível
853
     *
854
     * @param  string $cdata campo CDATA
855
     * @return string conteúdo do campo CDATA como string
856
     */
857
    protected function anfaveaDANFE($cdata = '')
858
    {
859
        if ($cdata == '') {
860
            return '';
861
        }
862
        //remove qualquer texto antes ou depois da tag CDATA
863
        $cdata = str_replace('<![CDATA[', '<CDATA>', $cdata);
864
        $cdata = str_replace(']]>', '</CDATA>', $cdata);
865
        $cdata = preg_replace('/\s\s+/', ' ', $cdata);
866
        $cdata = str_replace("> <", "><", $cdata);
867
        $len = strlen($cdata);
868
        $startPos = strpos($cdata, '<');
869
        if ($startPos === false) {
870
            return $cdata;
871
        }
872
        for ($x=$len; $x>0; $x--) {
873
            if (substr($cdata, $x, 1) == '>') {
874
                $endPos = $x;
875
                break;
876
            }
877
        }
878
        if ($startPos > 0) {
879
            $parte1 = substr($cdata, 0, $startPos);
880
        } else {
881
            $parte1 = '';
882
        }
883
        $parte2 = substr($cdata, $startPos, $endPos-$startPos+1);
0 ignored issues
show
Bug introduced by
The variable $endPos does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
884
        if ($endPos < $len) {
885
            $parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1);
886
        } else {
887
            $parte3 = '';
888
        }
889
        $texto = trim($parte1).' '.trim($parte3);
890
        if (strpos($parte2, '<CDATA>') === false) {
891
            $cdata = '<CDATA>'.$parte2.'</CDATA>';
892
        } else {
893
            $cdata = $parte2;
894
        }
895
        //carrega o xml CDATA em um objeto DOM
896
        $dom = new Dom();
897
        $dom->loadXML($cdata, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG);
898
        //$xml = $dom->saveXML();
899
        //grupo CDATA infADprod
900
        $id = $dom->getElementsByTagName('id')->item(0);
901
        $div = $dom->getElementsByTagName('div')->item(0);
902
        $entg = $dom->getElementsByTagName('entg')->item(0);
903
        $dest = $dom->getElementsByTagName('dest')->item(0);
904
        $ctl = $dom->getElementsByTagName('ctl')->item(0);
905
        $ref = $dom->getElementsByTagName('ref')->item(0);
906
        if (isset($id)) {
907
            if ($id->hasAttributes()) {
908
                foreach ($id->attributes as $attr) {
909
                    $name = $attr->nodeName;
910
                    $value = $attr->nodeValue;
911
                    $texto .= " $name : $value";
912
                }
913
            }
914
        }
915
        if (isset($div)) {
916
            if ($div->hasAttributes()) {
917
                foreach ($div->attributes as $attr) {
918
                    $name = $attr->nodeName;
919
                    $value = $attr->nodeValue;
920
                    $texto .= " $name : $value";
921
                }
922
            }
923
        }
924
        if (isset($entg)) {
925
            if ($entg->hasAttributes()) {
926
                foreach ($entg->attributes as $attr) {
927
                    $name = $attr->nodeName;
928
                    $value = $attr->nodeValue;
929
                    $texto .= " $name : $value";
930
                }
931
            }
932
        }
933
        if (isset($dest)) {
934
            if ($dest->hasAttributes()) {
935
                foreach ($dest->attributes as $attr) {
936
                    $name = $attr->nodeName;
937
                    $value = $attr->nodeValue;
938
                    $texto .= " $name : $value";
939
                }
940
            }
941
        }
942
        if (isset($ctl)) {
943
            if ($ctl->hasAttributes()) {
944
                foreach ($ctl->attributes as $attr) {
945
                    $name = $attr->nodeName;
946
                    $value = $attr->nodeValue;
947
                    $texto .= " $name : $value";
948
                }
949
            }
950
        }
951
        if (isset($ref)) {
952
            if ($ref->hasAttributes()) {
953
                foreach ($ref->attributes as $attr) {
954
                    $name = $attr->nodeName;
955
                    $value = $attr->nodeValue;
956
                    $texto .= " $name : $value";
957
                }
958
            }
959
        }
960
        //grupo CADATA infCpl
961
        $t = $dom->getElementsByTagName('transmissor')->item(0);
962
        $r = $dom->getElementsByTagName('receptor')->item(0);
963
        $versao = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
964
        'Versao:'.$dom->getElementsByTagName('versao')->item(0)->nodeValue.' ' : '';
965
        $especieNF = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
966
        'Especie:'.$dom->getElementsByTagName('especieNF')->item(0)->nodeValue.' ' : '';
967
        $fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
968
        'Entrega:'.$dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue.' ' : '';
969
        $dca = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
970
        'dca:'.$dom->getElementsByTagName('dca')->item(0)->nodeValue.' ' : '';
971
        $texto .= "".$versao.$especieNF.$fabEntrega.$dca;
972
        if (isset($t)) {
973
            if ($t->hasAttributes()) {
974
                $texto .= " Transmissor ";
975
                foreach ($t->attributes as $attr) {
976
                    $name = $attr->nodeName;
977
                    $value = $attr->nodeValue;
978
                    $texto .= " $name : $value";
979
                }
980
            }
981
        }
982
        if (isset($r)) {
983
            if ($r->hasAttributes()) {
984
                $texto .= " Receptor ";
985
                foreach ($r->attributes as $attr) {
986
                    $name = $attr->nodeName;
987
                    $value = $attr->nodeValue;
988
                    $texto .= " $name : $value";
989
                }
990
            }
991
        }
992
        return $texto;
993
    }
994
    
995
    protected static function getCardName($tBand)
996
    {
997
        switch ($tBand) {
998
            case '01':
999
                $tBandNome = 'VISA';
1000
                break;
1001
            case '02':
1002
                $tBandNome = 'MASTERCARD';
1003
                break;
1004
            case '03':
1005
                $tBandNome = 'AMERICAM EXPRESS';
1006
                break;
1007
            case '04':
1008
                $tBandNome = 'SOROCRED';
1009
                break;
1010
            case '99':
1011
                $tBandNome = 'OUTROS';
1012
                break;
1013
            default:
1014
                $tBandNome = '';
1015
        }
1016
        return $tBandNome;
1017
    }
1018
      
1019
    protected function checkCancelada()
1020
    {
1021
        if (!isset($this->nfeProc)) {
1022
            return false;
1023
        }
1024
        $cStat = $this->getTagValue($this->nfeProc, "cStat");
1025
        return $cStat == '101' ||
1026
                $cStat == '151' ||
1027
                $cStat == '135' ||
1028
                $cStat == '155';
1029
    }
1030
1031
    protected function checkDenegada()
1032
    {
1033
        if (!isset($this->nfeProc)) {
1034
            return false;
1035
        }
1036
        //NÃO ERA NECESSÁRIO ESSA FUNÇÃO POIS SÓ SE USA
1037
        //1 VEZ NO ARQUIVO INTEIRO
1038
        $cStat = $this->getTagValue($this->nfeProc, "cStat");
1039
        return $cStat == '110' ||
1040
               $cStat == '301' ||
1041
               $cStat == '302';
1042
    }
1043
}
1044