Passed
Push — master ( 0c506a...ba01e1 )
by Roberto
01:22 queued 11s
created

DanfeSimples::monta()   F

Complexity

Conditions 63
Paths 1536

Size

Total Lines 261

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 4032

Importance

Changes 0
Metric Value
cc 63
nc 1536
nop 1
dl 0
loc 261
ccs 0
cts 209
cp 0
crap 4032
rs 0
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*
3
 * Author Newton Pasqualini Filho (newtonpasqualini at gmail dot com)
4
 */
5
namespace NFePHP\DA\NFe;
6
7
use NFePHP\DA\Legacy\Dom;
8
use NFePHP\DA\Legacy\Pdf;
9
use NFePHP\DA\Common\DaCommon;
10
11
class DanfeSimples extends DaCommon
12
{
13
14
    /**
15
     * Tamanho do Papel
16
     *
17
     * @var string
18
     */
19
    public $papel = 'A5';
20
    /**
21
     * XML NFe
22
     *
23
     * @var string
24
     */
25
    protected $xml;
26
    /**
27
     * mesagens de erro
28
     *
29
     * @var string
30
     */
31
    protected $errMsg = '';
32
    /**
33
     * status de erro true um erro ocorreu false sem erros
34
     *
35
     * @var boolean
36
     */
37
    protected $errStatus = false;
38
    /**
39
     * Dom Document
40
     *
41
     * @var \NFePHP\DA\Legacy\Dom
42
     */
43
    protected $dom;
44
    /**
45
     * Node
46
     *
47
     * @var \DOMNode
48
     */
49
    protected $infNFe;
50
    /**
51
     * Node
52
     *
53
     * @var \DOMNode
54
     */
55
    protected $ide;
56
    /**
57
     * Node
58
     *
59
     * @var \DOMNode
60
     */
61
    protected $entrega;
62
    /**
63
     * Node
64
     *
65
     * @var \DOMNode
66
     */
67
    protected $retirada;
68
    /**
69
     * Node
70
     *
71
     * @var \DOMNode
72
     */
73
    protected $emit;
74
    /**
75
     * Node
76
     *
77
     * @var \DOMNode
78
     */
79
    protected $dest;
80
    /**
81
     * Node
82
     *
83
     * @var \DOMNode
84
     */
85
    protected $enderEmit;
86
    /**
87
     * Node
88
     *
89
     * @var \DOMNode
90
     */
91
    protected $enderDest;
92
    /**
93
     * Node
94
     *
95
     * @var \DOMNode
96
     */
97
    protected $det;
98
    /**
99
     * Node
100
     *
101
     * @var \DOMNode
102
     */
103
    protected $cobr;
104
    /**
105
     * Node
106
     *
107
     * @var \DOMNode
108
     */
109
    protected $dup;
110
    /**
111
     * Node
112
     *
113
     * @var \DOMNode
114
     */
115
    protected $ICMSTot;
116
    /**
117
     * Node
118
     *
119
     * @var \DOMNode
120
     */
121
    protected $ISSQNtot;
122
    /**
123
     * Node
124
     *
125
     * @var \DOMNode
126
     */
127
    protected $transp;
128
    /**
129
     * Node
130
     *
131
     * @var \DOMNode
132
     */
133
    protected $transporta;
134
    /**
135
     * Node
136
     *
137
     * @var \DOMNode
138
     */
139
    protected $veicTransp;
140
    /**
141
     * Node reboque
142
     *
143
     * @var \DOMNode
144
     */
145
    protected $reboque;
146
    /**
147
     * Node infAdic
148
     *
149
     * @var \DOMNode
150
     */
151
    protected $infAdic;
152
    /**
153
     * Tipo de emissão
154
     *
155
     * @var integer
156
     */
157
    protected $tpEmis;
158
    /**
159
     * Node infProt
160
     *
161
     * @var \DOMNode
162
     */
163
    protected $infProt;
164
    /**
165
     * 1-Retrato/ 2-Paisagem
166
     *
167
     * @var integer
168
     */
169
    protected $tpImp;
170
    /**
171
     * Node compra
172
     *
173
     * @var \DOMNode
174
     */
175
    protected $compra;
176
177
    /*
178
     * Guarda a estrutura da NF como Array para
179
     * interagir de maneira nativa com os dados
180
     * do XML da NFe
181
     */
182
    protected $nfeArray = [];
183
184
    /**
185
     * __construct
186
     *
187
     * @name  __construct
188
     *
189
     * @param string $xml Conteúdo XML da NF-e (com ou sem a tag nfeProc)
190
     */
191
    public function __construct($xml, $orientacao = 'P')
192
    {
193
        $this->loadDoc($xml);
194
        $this->orientacao = $orientacao;
195
    }
196
197
    private function loadDoc($xml)
198
    {
199
        $this->xml = $xml;
200
        if (!empty($xml)) {
201
            $stdClass = simplexml_load_string($xml);
202
            $json = json_encode($stdClass, JSON_OBJECT_AS_ARRAY);
203
            $this->nfeArray = json_decode($json, JSON_OBJECT_AS_ARRAY);
204
            if (!isset($this->nfeArray['NFe']['infNFe']['@attributes']['Id'])) {
205
                throw new Exception('XML não parece ser uma NF-e!');
206
            }
207
            if ($this->nfeArray['protNFe']['infProt']['cStat'] != '100') {
208
                throw new Exception('NF-e não autorizada!');
209
            }
210
        }
211
    }
212
213
    protected function monta(
214
        $logo = ''
215
    ) {
216
        $this->pdf       = '';
0 ignored issues
show
Documentation Bug introduced by
It seems like '' of type string is incompatible with the declared type object<NFePHP\DA\Legacy\Pdf> of property $pdf.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
217
        $this->logomarca = $this->adjustImage($logo);
218
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
219
        if (empty($this->orientacao)) {
220
            $this->orientacao = 'L';
221
        }
222
223
224
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
225
        if ($this->orientacao == 'L') {
226
            if ($this->papel == 'A5') {
227
                $this->maxW = 210;
0 ignored issues
show
Documentation Bug introduced by
The property $maxW was declared of type double, but 210 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
228
                $this->maxH = 148;
0 ignored issues
show
Documentation Bug introduced by
The property $maxH was declared of type double, but 148 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
229
            } elseif (is_array($this->papel)) {
230
                $this->maxW = $this->papel[0];
231
                $this->maxH = $this->papel[1];
232
            }
233
        } else {
234
            if ($this->papel == 'A5') {
235
                $this->maxW = 148;
0 ignored issues
show
Documentation Bug introduced by
The property $maxW was declared of type double, but 148 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
236
                $this->maxH = 210;
0 ignored issues
show
Documentation Bug introduced by
The property $maxH was declared of type double, but 210 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
237
            } elseif (is_array($this->papel)) {
238
                $this->maxW = $this->papel[0];
239
                $this->maxH = $this->papel[1];
240
            }
241
        }
242
243
        //Caso a largura da etiqueta seja pequena <=110mm,
244
        //Definimos como pequeno, para diminuir as fontes e tamanhos das células
245
        if ($this->maxW <= 130) {
246
            $pequeno = true;
247
        } else {
248
            $pequeno = false;
249
        }
250
251
        // estabelece contagem de paginas
252
        $this->pdf->aliasNbPages();
253
        // fixa as margens
254
        $this->pdf->setMargins($this->margesq, $this->margsup);
255
        $this->pdf->setDrawColor(0, 0, 0);
256
        $this->pdf->setFillColor(255, 255, 255);
257
        // inicia o documento
258
        $this->pdf->open();
259
        // adiciona a primeira página
260
        $this->pdf->addPage($this->orientacao, $this->papel);
0 ignored issues
show
Bug introduced by
It seems like $this->papel can also be of type array; however, NFePHP\DA\Legacy\FPDF\Fpdf::addPage() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
261
        $this->pdf->setLineWidth(0.1);
262
        $this->pdf->settextcolor(0, 0, 0);
263
        //Configura o pagebreak para não quebrar com 2cm do bottom.
264
        $this->pdf->setAutoPageBreak(true, $this->margsup);
265
266
267
        // LINHA 1
268
        $this->pdf->setFont('Arial', 'B', $pequeno ? 10 : 12);
269
        $this->pdf->cell(
270
            ($this->maxW - ($this->margesq * 2)),
271
            $pequeno ? 5 : 6,
272
            "DANFE SIMPLIFICADO - ETIQUETA",
273
            1,
274
            1,
275
            'C',
276
            1
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
277
        );
278
279
        // LINHA 2
280
        $dataEmissao = date('d/m/Y', strtotime("{$this->nfeArray['NFe']['infNFe']['ide']['dhEmi']}"));
281
        $c1 = ($this->maxW - ($this->margesq * 2)) / 4;
282
        $this->pdf->setFont('Arial', 'B', $pequeno ? 8 : 10);
283
        $this->pdf->cell($c1, $pequeno ? 4 : 5, "TIPO NF", 1, 0, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
284
        $this->pdf->setFont('Arial', '', 10);
285
        $this->pdf->cell(
286
            $c1,
287
            5,
288
            "{$this->nfeArray['NFe']['infNFe']['ide']['tpNF']} - " .
289
                                  ($this->nfeArray['NFe']['infNFe']['ide']['tpNF']==1 ? 'Saida':'Entrada'),
290
            1,
291
            0,
292
            'C',
293
            1
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
294
        );
295
        $this->pdf->setFont('Arial', 'B', $pequeno ? 8 : 10);
296
        $this->pdf->cell($c1, $pequeno ? 4 : 5, "DATA EMISSAO", 1, 0, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
297
        $this->pdf->setFont('Arial', '', 10);
298
        $this->pdf->cell($c1, $pequeno ? 4 : 5, "{$dataEmissao}", 1, 1, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
299
300
        // LINHA 3
301
        $this->pdf->setFont('Arial', 'B', $pequeno ? 8 : 10);
302
        $this->pdf->cell($c1, $pequeno ? 4 : 5, "NUMERO", 1, 0, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
303
        $this->pdf->setFont('Arial', '', 10);
304
        $this->pdf->cell($c1, $pequeno ? 4 : 5, "{$this->nfeArray['NFe']['infNFe']['ide']['nNF']}", 1, 0, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
305
        $this->pdf->setFont('Arial', 'B', $pequeno ? 8 : 10);
306
        $this->pdf->cell($c1, $pequeno ? 4 : 5, "SERIE", 1, 0, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
307
        $this->pdf->setFont('Arial', '', 10);
308
        $this->pdf->cell($c1, $pequeno ? 4 : 5, "{$this->nfeArray['NFe']['infNFe']['ide']['serie']}", 1, 1, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
309
310
        // LINHA 4
311
        $chave = substr($this->nfeArray['NFe']['infNFe']['@attributes']['Id'], 3);
312
        $this->pdf->setFont('Arial', 'B', $pequeno ? 7 : 10);
313
        $this->pdf->cell($c1, $pequeno ? 4 : 5, "CHAVE DE ACESSO", 1, 0, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
314
        $this->pdf->setFont('Arial', '', $pequeno ? 8 : 10);
315
        $this->pdf->cell(($c1 * 3), $pequeno ? 4 : 5, "{$chave}", 1, 1, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
316
317
        // LINHA 5
318
        $this->pdf->setFont('Arial', 'B', $pequeno ? 8 : 10);
319
        $this->pdf->cell($c1, $pequeno ? 4 : 5, "PROTOCOLO", 1, 0, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
320
        $this->pdf->setFont('Arial', '', 10);
321
        $dataProto = date("d/m/Y H:i:s", strtotime($this->nfeArray['protNFe']['infProt']['dhRecbto']));
322
        $this->pdf->cell(
323
            ($c1 * 3),
324
            $pequeno ? 4 : 5,
325
            "{$this->nfeArray['protNFe']['infProt']['nProt']} - {$dataProto}",
326
            1,
327
            1,
328
            'C',
329
            1
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
330
        );
331
332
        $this->pdf->ln();
333
        $y = $this->pdf->getY();
334
        $this->pdf->setFillColor(0, 0, 0);
335
        if ($pequeno) {
336
            //caso seja etiqueta pequena, aumenta o code128 para
337
            //que uma impressora de 203dpi consiga imprimir um código legível
338
            $this->pdf->code128($this->margesq * 2, $y, $chave, ($this->maxW - $this->margesq * 4), 15);
339
        } else {
340
            $this->pdf->code128(($c1/2), $y, $chave, ($c1 * 3), 15);
341
        }
342
        $this->pdf->setFillColor(255, 255, 255);
343
        $this->pdf->ln();
344
        $this->pdf->ln();
345
        $this->pdf->ln();
346
        $this->pdf->ln();
347
        $this->pdf->ln();
348
349
        // LINHA 6
350
        $this->pdf->setFont('Arial', 'B', $pequeno ? 10 : 12);
351
        $this->pdf->cell(($c1 * 4), $pequeno ? 5 : 6, "EMITENTE", 1, 1, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
352
353
        // LINHA 7
354
        $this->pdf->setFont('Arial', '', $pequeno ? 9 : 10);
355
        $this->pdf->multiCell(
356
            ($c1 * 4),
357
            $pequeno ? 4 : 5,
358
            "{$this->nfeArray['NFe']['infNFe']['emit']['xNome']}",
359
            1,
360
            'C',
361
            false
362
        );
363
364
        // LINHA 8
365
        $cpfCnpj = (isset($this->nfeArray['NFe']['infNFe']['emit']['CNPJ'])
366
            ? $this->nfeArray['NFe']['infNFe']['emit']['CNPJ']
367
            :$this->nfeArray['NFe']['infNFe']['emit']['CPF']);
368
        $this->pdf->cell(($c1 * 2), $pequeno ? 4 : 5, "CNPJ/CPF {$cpfCnpj}", 1, 0, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
369
        $this->pdf->cell(
370
            ($c1 * 2),
371
            $pequeno ? 4 : 5,
372
            @"RG/IE {$this->nfeArray['NFe']['infNFe']['emit']['IE']}",
373
            1,
374
            1,
375
            'C',
376
            1
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
377
        );
378
379
        $enderecoEmit  = "{$this->nfeArray['NFe']['infNFe']['emit']['enderEmit']['xMun']}"
380
                       . " / {$this->nfeArray['NFe']['infNFe']['emit']['enderEmit']['UF']}"
381
                       . " - CEP {$this->nfeArray['NFe']['infNFe']['emit']['enderEmit']['CEP']}";
382
383
        // LINHA 9
384
        $this->pdf->setFont('Arial', '', $pequeno ? 9 : 10);
385
        $this->pdf->cell(($c1 * 4), $pequeno ? 4 : 5, "{$enderecoEmit}", 1, 1, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
386
387
        // LINHA 10
388
        $this->pdf->setFont('Arial', 'B', $pequeno ? 10 : 12);
389
        $this->pdf->cell(($c1 * 4), $pequeno ? 5 : 6, "DESTINATARIO", 1, 1, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
390
391
        // LINHA 11
392
        $this->pdf->setFont('Arial', '', $pequeno ? 9 : 10);
393
        $this->pdf->multiCell(
394
            ($c1 * 4),
395
            $pequeno ? 4 : 5,
396
            "{$this->nfeArray['NFe']['infNFe']['dest']['xNome']}",
397
            1,
398
            'C',
399
            false
400
        );
401
402
        // LINHA 12
403
        $cpfCnpj = (isset($this->nfeArray['NFe']['infNFe']['dest']['CNPJ'])
404
            ? $this->nfeArray['NFe']['infNFe']['dest']['CNPJ']
405
            :$this->nfeArray['NFe']['infNFe']['dest']['CPF']);
406
        $this->pdf->cell(($c1 * 2), $pequeno ? 4 : 5, "CNPJ/CPF {$cpfCnpj}", 1, 0, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
407
        $this->pdf->cell(
408
            ($c1 * 2),
409
            $pequeno ? 4 : 5,
410
            @"RG/IE {$this->nfeArray['NFe']['infNFe']['dest']['IE']}",
411
            1,
412
            1,
413
            'C',
414
            1
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
415
        );
416
417
        if (isset($this->nfeArray['NFe']['infNFe']['entrega'])) {
418
            $enderecoLinha1 = "{$this->nfeArray['NFe']['infNFe']['entrega']['xLgr']}";
419
            if (!empty($this->nfeArray['NFe']['infNFe']['entrega']['nro'])) {
420
                $enderecoLinha1 .= ", {$this->nfeArray['NFe']['infNFe']['entrega']['nro']}";
421
            }
422
            $enderecoLinha2 = '';
423
            if (!empty($this->nfeArray['NFe']['infNFe']['entrega']['xCpl'])) {
424
                $enderecoLinha2 .= "{$this->nfeArray['NFe']['infNFe']['entrega']['xCpl']} - ";
425
            }
426
            $enderecoLinha2 .= "{$this->nfeArray['NFe']['infNFe']['entrega']['xMun']}"
427
                             . " / {$this->nfeArray['NFe']['infNFe']['entrega']['UF']}"
428
                             . " - CEP {$this->nfeArray['NFe']['infNFe']['entrega']['CEP']}";
429
        } else {
430
            $enderecoLinha1 = "{$this->nfeArray['NFe']['infNFe']['dest']['enderDest']['xLgr']}";
431
            if (!empty($this->nfeArray['NFe']['infNFe']['dest']['enderDest']['nro'])) {
432
                $enderecoLinha1 .= ", {$this->nfeArray['NFe']['infNFe']['dest']['enderDest']['nro']}";
433
            }
434
            $enderecoLinha2 = '';
435
            if (!empty($this->nfeArray['NFe']['infNFe']['dest']['enderDest']['xCpl'])) {
436
                $enderecoLinha2 .= "{$this->nfeArray['NFe']['infNFe']['dest']['enderDest']['xCpl']} - ";
437
            }
438
            $enderecoLinha2 .= "{$this->nfeArray['NFe']['infNFe']['dest']['enderDest']['xMun']}"
439
                             . " / {$this->nfeArray['NFe']['infNFe']['dest']['enderDest']['UF']}"
440
                             . " - CEP {$this->nfeArray['NFe']['infNFe']['dest']['enderDest']['CEP']}";
441
        }
442
443
        // LINHA 13
444
        $this->pdf->setFont('Arial', '', $pequeno ? 9 : 10);
445
        $this->pdf->cell(($c1 * 4), $pequeno ? 4 : 5, "{$enderecoLinha1}", 1, 1, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
446
447
        // LINHA 14
448
        $this->pdf->setFont('Arial', '', $pequeno ? 9 : 10);
449
        $this->pdf->cell(($c1 * 4), $pequeno ? 4 : 5, "{$enderecoLinha2}", 1, 1, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
450
451
        // LINHA 15
452
        $this->pdf->setFont('Arial', 'B', $pequeno ? 10 : 12);
453
        $this->pdf->cell(($c1 * 2), $pequeno ? 5 : 6, "TOTAL DA NF-e", 1, 0, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
454
        $this->pdf->setFont('Arial', '', $pequeno ? 9 : 10);
455
        $vNF = number_format($this->nfeArray['NFe']['infNFe']['total']['ICMSTot']['vNF'], 2, ',', '.');
456
        $this->pdf->cell(($c1 * 2), $pequeno ? 5 : 6, "R$ {$vNF}", 1, 1, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
457
458
        // LINHA 16
459
        $this->pdf->setFont('Arial', 'B', $pequeno ? 10 : 12);
460
        $this->pdf->cell(($c1 * 4), $pequeno ? 5 : 6, "DADOS ADICIONAIS", 1, 1, 'C', 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

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...
461
462
        // LINHA 11
463
        $this->pdf->setFont('Arial', '', $pequeno ? 8 : 10);
464
        $this->pdf->multiCell(
465
            ($c1 * 4),
466
            $pequeno ? 3 : 5,
467
            "{$this->nfeArray['NFe']['infNFe']['infAdic']['infCpl']}",
468
            1,
469
            1,
470
            'J',
0 ignored issues
show
Documentation introduced by
'J' is of type string, but the function expects a boolean.

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...
471
            1
0 ignored issues
show
Unused Code introduced by
The call to Pdf::multicell() has too many arguments starting with 1.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
472
        );
473
    }
474
}
475