Passed
Push — master ( d3f5b9...393546 )
by Roberto
03:36 queued 01:07
created

Dacte::zModalAquaviario()   F

Complexity

Conditions 17
Paths 240

Size

Total Lines 161

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 306

Importance

Changes 0
Metric Value
cc 17
nc 240
nop 2
dl 0
loc 161
ccs 0
cts 161
cp 0
crap 306
rs 3.1065
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
namespace NFePHP\DA\CTe;
3
4
/**
5
 * Classe para ageração do PDF da CTe, conforme regras e estruturas
6
 * estabelecidas pela SEFAZ.
7
 *
8
 * @category  Library
9
 * @package   nfephp-org/sped-da
10
 * @name      Dacte .php
11
 * @copyright 2009-2016 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 L. Machado <linux dot rlm at gmail dot com>
15
 */
16
use Com\Tecnick\Barcode\Barcode;
17
use Exception;
18
use NFePHP\DA\Legacy\Dom;
19
use NFePHP\DA\Legacy\Pdf;
20
use NFePHP\DA\Legacy\Common;
21
22
class Dacte extends Common
23
{
24
    const NFEPHP_SITUACAO_EXTERNA_CANCELADA = 1;
25
    const NFEPHP_SITUACAO_EXTERNA_DENEGADA = 2;
26
    const SIT_DPEC = 3;
27
    protected $logoAlign = 'C';
28
    protected $yDados = 0;
29
    protected $situacao_externa = 0;
30
    protected $numero_registro_dpec = '';
31
    protected $pdf;
32
    protected $xml;
33
    protected $logomarca = '';
34
    protected $errMsg = '';
35
    protected $errStatus = false;
36
    protected $orientacao = 'P';
37
    protected $papel = 'A4';
38
    protected $destino = 'I';
39
    protected $pdfDir = '';
40
    protected $fontePadrao = 'Times';
41
    protected $version = '1.3.0';
42
    protected $wPrint;
43
    protected $hPrint;
44
    protected $dom;
45
    protected $infCte;
46
    protected $infCteComp;
47
    protected $infCteAnu;
48
    protected $chaveCTeRef;
49
    protected $tpCTe;
50
    protected $ide;
51
    protected $emit;
52
    protected $enderEmit;
53
    protected $rem;
54
    protected $enderReme;
55
    protected $dest;
56
    protected $enderDest;
57
    protected $exped;
58
    protected $enderExped;
59
    protected $receb;
60
    protected $enderReceb;
61
    protected $infCarga;
62
    protected $infQ;
63
    protected $seg;
64
    protected $modal;
65
    protected $rodo;
66
    protected $moto;
67
    protected $veic;
68
    protected $ferrov;
69
    protected $Comp;
70
    protected $infNF;
71
    protected $infNFe;
72
    protected $compl;
73
    protected $ICMS;
74
    protected $ICMSSN;
75
    protected $ICMSOutraUF;
76
    protected $imp;
77
    protected $toma4;
78
    protected $toma03;
79
    protected $tpEmis;
80
    protected $tpImp;
81
    protected $tpAmb;
82
    protected $vPrest;
83
    protected $wAdic = 150;
84
    protected $textoAdic = '';
85
    protected $debugMode = 2;
86
    protected $formatPadrao;
87
    protected $formatNegrito;
88
    protected $aquav;
89
    protected $preVisualizar;
90
    protected $flagDocOrigContinuacao;
91
    protected $arrayNFe = array();
92
    protected $siteDesenvolvedor;
93
    protected $nomeDesenvolvedor;
94
    protected $totPag;
95
    protected $idDocAntEle = [];
96
    protected $qrCodCTe;
97
    protected $margemInterna = 0;
98
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
99
100
    /**
101
     * __construct
102
     *
103
     * @param string $docXML Arquivo XML da CTe
104
     * @param string $sOrientacao (Opcional) Orientação da impressão P ou L
105
     * @param string $sPapel Tamanho do papel (Ex. A4)
106
     * @param string $sPathLogo Caminho para o arquivo do logo
107
     * @param string $sDestino Estabelece a direção do envio do documento PDF
108
     * @param string $sDirPDF Caminho para o diretorio de armaz. dos PDF
109
     * @param string $fonteDACTE Nome da fonte a ser utilizada
110
     * @param number $mododebug 0-Não 1-Sim e 2-nada (2 default)
111
     * @param string $preVisualizar 0-Não 1-Sim
112
     * @param string $nomeDesenvolvedor Nome do desenvolvedor
113
     * @param string $siteDesenvolvedor Site do desenvolvedor
114
     */
115
    public function __construct(
116
        $docXML = '',
117
        $sOrientacao = '',
118
        $sPapel = '',
119
        $sPathLogo = '',
120
        $sDestino = 'I',
121
        $sDirPDF = '',
122
        $fonteDACTE = '',
123
        $mododebug = 2,
124
        $preVisualizar = false,
125
        $nomeDesenvolvedor = 'Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org',
126
        $siteDesenvolvedor = 'http://www.nfephp.org'
127
    ) {
128
        if (is_numeric($mododebug)) {
129
            $this->debugMode = $mododebug;
0 ignored issues
show
Documentation Bug introduced by
It seems like $mododebug can also be of type double or string. However, the property $debugMode is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
130
        }
131
        if ($mododebug == 1) {
132
            //ativar modo debug
133
            error_reporting(E_ALL);
134
            ini_set('display_errors', 'On');
135
        } elseif ($mododebug == 0) {
136
            //desativar modo debug
137
            error_reporting(0);
138
            ini_set('display_errors', 'Off');
139
        }
140
        $this->orientacao = $sOrientacao;
141
        $this->papel = $sPapel;
142
        $this->pdf = '';
143
        $this->xml = $docXML;
144
        $this->logomarca = $sPathLogo;
145
        $this->destino = $sDestino;
146
        $this->pdfDir = $sDirPDF;
147
        $this->preVisualizar = $preVisualizar;
148
        $this->siteDesenvolvedor = $siteDesenvolvedor;
149
        $this->nomeDesenvolvedor = $nomeDesenvolvedor;
150
        // verifica se foi passa a fonte a ser usada
151
        if (!empty($fonteDACTE)) {
152
            $this->fontePadrao = $fonteDACTE;
153
        }
154
        $this->formatPadrao = array(
155
            'font' => $this->fontePadrao,
156
            'size' => 6,
157
            'style' => '');
158
        $this->formatNegrito = array(
159
            'font' => $this->fontePadrao,
160
            'size' => 7,
161
            'style' => 'B');
162
        //se for passado o xml
163
        if (!empty($this->xml)) {
164
            $this->dom = new Dom();
165
            $this->dom->loadXML($this->xml);
166
            $this->cteProc = $this->dom->getElementsByTagName("cteProc")->item(0);
0 ignored issues
show
Bug introduced by
The property cteProc 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...
167
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
168
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
169
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
170
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
171
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
172
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
173
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
174
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
175
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
176
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
177
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
178
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
179
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
180
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
181
            $this->infQ = $this->dom->getElementsByTagName("infQ");
182
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
183
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
184
            $this->aereo = $this->dom->getElementsByTagName("aereo")->item(0);
0 ignored issues
show
Bug introduced by
The property aereo 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->lota = $this->getTagValue($this->rodo, "lota");
0 ignored issues
show
Bug introduced by
The property lota 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...
186
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
187
            $this->veic = $this->dom->getElementsByTagName("veic");
188
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
189
            // adicionar outros modais
190
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
191
            $this->infCteAnu = $this->dom->getElementsByTagName("infCteAnu")->item(0);
192
            if ($this->tpCTe == 1) {
193
                $this->chaveCTeRef = $this->getTagValue($this->infCteComp, "chCTe");
194
            } else {
195
                $this->chaveCTeRef = $this->getTagValue($this->infCteAnu, "chCte");
196
            }
197
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
198
            $this->Comp = $this->dom->getElementsByTagName("Comp");
199
            $this->infNF = $this->dom->getElementsByTagName("infNF");
200
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
201
            $this->infOutros = $this->dom->getElementsByTagName("infOutros");
0 ignored issues
show
Bug introduced by
The property infOutros 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...
202
            $this->compl = $this->dom->getElementsByTagName("compl");
203
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
204
            $this->ICMSSN = $this->dom->getElementsByTagName("ICMSSN")->item(0);
205
            $this->ICMSOutraUF = $this->dom->getElementsByTagName("ICMSOutraUF")->item(0);
206
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
207
            if (!empty($this->getTagValue($this->imp, "vTotTrib"))) {
208
                $textoAdic = number_format($this->getTagValue($this->imp, "vTotTrib"), 2, ",", ".");
209
                $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
210
                        .$textoAdic;
211
            }
212
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
213
            $this->toma03 = $this->dom->getElementsByTagName("toma3")->item(0);
214
            //Tag tomador é identificado por toma03 na versão 2.00
215
            if ($this->infCte->getAttribute("versao")=="2.00") {
216
                $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
217
            }
218
            //modal aquaviário
219
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
220
            $tomador = $this->getTagValue($this->toma03, "toma");
221
            //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4-Outros
222
            switch ($tomador) {
223
                case '0':
224
                    $this->toma = $this->rem;
0 ignored issues
show
Bug introduced by
The property toma 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...
225
                    $this->enderToma = $this->enderReme;
0 ignored issues
show
Bug introduced by
The property enderToma 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...
226
                    break;
227
                case '1':
228
                    $this->toma = $this->exped;
229
                    $this->enderToma = $this->enderExped;
230
                    break;
231
                case '2':
232
                    $this->toma = $this->receb;
233
                    $this->enderToma = $this->enderReceb;
234
                    break;
235
                case '3':
236
                    $this->toma = $this->dest;
237
                    $this->enderToma = $this->enderDest;
238
                    break;
239
                default:
240
                    $this->toma = $this->toma4;
241
                    $this->enderToma = $this->getTagValue($this->toma4, "enderToma");
242
                    break;
243
            }
244
            $this->tpEmis = $this->getTagValue($this->ide, "tpEmis");
245
            $this->tpImp = $this->getTagValue($this->ide, "tpImp");
246
            $this->tpAmb = $this->getTagValue($this->ide, "tpAmb");
247
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
248
            $this->qrCodCTe = $this->dom->getElementsByTagName('qrCodCTe')->item(0) ?
249
                $this->dom->getElementsByTagName('qrCodCTe')->item(0)->nodeValue : 'SEM INFORMAÇÃO DE QRCODE';
250
            $this->protCTe = $this->dom->getElementsByTagName("protCTe")->item(0);
0 ignored issues
show
Bug introduced by
The property protCTe 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...
251
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
252
            $this->modal = $this->getTagValue($this->ide, "modal");
253
        }
254
    }
255
256
    /**
257
     * monta
258
     * @param string $orientacao L ou P
259
     * @param string $papel A4
260
     * @param string $logoAlign C, L ou R
261
     * @param Pdf $classPDF
262
     * @return string montagem
263
     */
264
    public function monta(
265
        $orientacao = '',
266
        $papel = 'A4',
267
        $logoAlign = 'C',
268
        $classPDF = false
269
    ) {
270
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 268 can also be of type object<NFePHP\DA\Legacy\Pdf>; however, NFePHP\DA\CTe\Dacte::montaDACTE() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
271
    }
272
273
    /**
274
     * printDocument
275
     * @param string $nome
276
     * @param string $destino
277
     * @param string $printer
278
     * @return
279
     */
280
    public function printDocument($nome = '', $destino = 'I', $printer = '')
281
    {
282
        return $this->printDACTE($nome, $destino, $printer);
283
    }
284
285
    /**
286
     * Dados brutos do PDF
287
     * @return string
288
     */
289
    public function render()
290
    {
291
        return $this->pdf->getPdf();
292
    }
293
    protected function cteDPEC()
294
    {
295
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
296
    }
297
298
    /**
299
     * montaDACTE
300
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
301
     * durante sua construção.
302
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
303
     * pelo conteúdo da funçao e podem ser modificados.
304
     *
305
     * @param  string $orientacao (Opcional) Estabelece a orientação da
306
     *                impressão (ex. P-retrato), se nada for fornecido será
307
     *                usado o padrão da NFe
308
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
309
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
310
     */
311
    public function montaDACTE(
312
        $orientacao = '',
313
        $papel = 'A4',
314
        $logoAlign = 'C',
315
        $classPDF = false
316
    ) {
317
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
318
        if ($orientacao == '') {
319
            if ($this->tpImp == '1') {
320
                $orientacao = 'P';
321
            } else {
322
                $orientacao = 'P';
323
            }
324
        }
325
        $this->orientacao = $orientacao;
326
        $this->papel = $papel;
327
        $this->logoAlign = $logoAlign;
328
        //$this->situacao_externa = $situacao_externa;
329
        //instancia a classe pdf
330
        if ($classPDF !== false) {
331
            $this->pdf = $classPDF;
332
        } else {
333
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
334
        }
335
        if ($this->orientacao == 'P') {
336
            // margens do PDF
337
            $margSup = 2;
338
            $margEsq = 2;
339
            $margDir = 2;
340
            // posição inicial do relatorio
341
            $xInic = 1;
342
            $yInic = 1;
343
            if ($papel == 'A4') {
344
                //A4 210x297mm
345
                $maxW = 210;
346
                $maxH = 297;
347
            }
348
        } else {
349
            // margens do PDF
350
            $margSup = 3;
351
            $margEsq = 3;
352
            $margDir = 3;
353
            // posição inicial do relatorio
354
            $xInic = 5;
355
            $yInic = 5;
356
            if ($papel == 'A4') {
357
                //A4 210x297mm
358
                $maxH = 210;
359
                $maxW = 297;
360
                $this->wCanhoto = 25;
0 ignored issues
show
Bug introduced by
The property wCanhoto 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...
361
            }
362
        }
363
        //total inicial de paginas
364
        $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...
365
        //largura imprimivel em mm
366
        $this->wPrint = $maxW - ($margEsq + $xInic);
0 ignored issues
show
Bug introduced by
The variable $maxW 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...
367
        //comprimento imprimivel em mm
368
        $this->hPrint = $maxH - ($margSup + $yInic);
0 ignored issues
show
Bug introduced by
The variable $maxH 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...
369
        // estabelece contagem de paginas
370
        $this->pdf->aliasNbPages();
371
        // fixa as margens
372
        $this->pdf->setMargins($margEsq, $margSup, $margDir);
373
        $this->pdf->setDrawColor(0, 0, 0);
374
        $this->pdf->setFillColor(255, 255, 255);
375
        // inicia o documento
376
        $this->pdf->Open();
377
        // adiciona a primeira página
378
        $this->pdf->addPage($this->orientacao, $this->papel);
379
        $this->pdf->setLineWidth(0.1);
380
        $this->pdf->setTextColor(0, 0, 0);
381
        //calculo do numero de páginas ???
382
        $totPag = 1;
383
        //montagem da primeira página
384
        $pag = 1;
385
        $x = $xInic;
386
        $y = $yInic;
387
        //coloca o cabeçalho
388
        $y = $this->canhoto($x, $y);
389
        $y += 24;
390
        $r = $this->cabecalho($x, $y, $pag, $totPag);
0 ignored issues
show
Unused Code introduced by
$r 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...
391
        $y += 70;
392
        $r = $this->remetente($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
393
        $x = $this->wPrint * 0.5 + 2;
394
        $r = $this->destinatario($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
395
        $y += 19;
396
        $x = $xInic;
397
        $r = $this->expedidor($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
398
        $x = $this->wPrint * 0.5 + 2;
399
        $r = $this->recebedor($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
400
        $y += 19;
401
        $x = $xInic;
402
        $r = $this->tomador($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
403
        if ($this->tpCTe == '0') {
404
            //Normal
405
            $y += 10;
406
            $x = $xInic;
407
            $r = $this->descricaoCarga($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
408
            $y += 17;
409
            $x = $xInic;
410
            $r = $this->compValorServ($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
411
            $y += 25;
412
            $x = $xInic;
413
            $r = $this->impostos($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
414
            $y += 13;
415
            $x = $xInic;
416
            $r = $this->docOrig($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
417
            if ($this->modal == '1') {
418
                if ($this->lota == 1) {
419
                    //$y += 24.95;
420
                    $y += 35;
421
                } else {
422
                    $y += 53;
423
                }
424
            } elseif ($this->modal == '2') {
425
                $y += 53;
426
            } elseif ($this->modal == '3') {
427
                $y += 37.75;
428
            } else {
429
                $y += 24.95;
430
            }
431
            $x = $xInic;
432
            $r = $this->observacao($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
433
            $y = $y-6;
434
            switch ($this->modal) {
435
                case '1':
436
                    $y += 25.9;
437
                    $x = $xInic;
438
                    $r = $this->modalRod($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
439
                    break;
440
                case '2':
441
                    $y += 25.9;
442
                    $x = $xInic;
443
                    $r = $this->modalAereo($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
444
                    break;
445
                case '3':
446
                    $y += 17.9;
447
                    $x = $xInic;
448
                    $r = $this->modalAquaviario($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
449
                    break;
450
                case '4':
451
                    $y += 17.9;
452
                    $x = $xInic;
453
                    $r = $this->modalFerr($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
454
                    break;
455
                case '5':
456
                    $y += 17.9;
457
                    $x = $xInic;
458
                    // TODO fmertins 31/10/14: este método não existe...
459
                    $r = $this->modalDutoviario($x, $y);
0 ignored issues
show
Bug introduced by
The method modalDutoviario() does not seem to exist on object<NFePHP\DA\CTe\Dacte>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Unused Code introduced by
$r 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...
460
                    break;
461
            }
462
            if ($this->modal == '1') {
463
                if ($this->lota == 1) {
464
                    $y += 37;
465
                } else {
466
                    $y += 8.9;
467
                }
468
            } elseif ($this->modal == '2') {
469
                $y += 8.9;
470
            } elseif ($this->modal == '3') {
471
                $y += 24.15;
472
            } else {
473
                $y += 37;
474
            }
475
        } else {
476
            //$r = $this->cabecalho(1, 1, $pag, $totPag);
477
            //Complementado
478
            $y += 10;
479
            $x = $xInic;
480
            $r = $this->docCompl($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
481
            $y += 80;
482
            $x = $xInic;
483
            $r = $this->compValorServ($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
484
            $y += 25;
485
            $x = $xInic;
486
            $r = $this->impostos($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
487
            $y += 13;
488
            $x = $xInic;
489
            $r = $this->observacao($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
490
            $y += 15;
491
        }
492
        $x = $xInic;
493
        $r = $this->dadosAdic($x, $y, $pag, $totPag);
0 ignored issues
show
Unused Code introduced by
$r 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...
494
        //$y += 19;
495
        //$y += 11;
496
        //$y = $this->canhoto($x, $y);
497
        //coloca o rodapé da página
498
        if ($this->orientacao == 'P') {
499
            $this->rodape(2, $this->hPrint - 2);
500
        } else {
501
            $this->rodape($xInic, $this->hPrint + 2.3);
502
        }
503
        if ($this->flagDocOrigContinuacao == 1) {
504
            $this->docOrigContinuacao(1, 71);
505
        }
506
        //retorna o ID na CTe
507
        if ($classPDF !== false) {
508
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
509
            return $aR;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $aR; (array) is incompatible with the return type documented by NFePHP\DA\CTe\Dacte::montaDACTE of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
510
        } else {
511
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
512
        }
513
    }
514
515
    /**
516
     * printDACTE
517
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
518
     * O destino da impressão pode ser :
519
     * I-browser
520
     * D-browser com download
521
     * F-salva em um arquivo local com o nome informado
522
     * S-retorna o documento como uma string e o nome é ignorado.
523
     * Para enviar o pdf diretamente para uma impressora indique o
524
     * nome da impressora e o destino deve ser 'S'.
525
     *
526
     * @param  string $nome Path completo com o nome do arquivo pdf
527
     * @param  string $destino Direção do envio do PDF
528
     * @param  string $printer Identificação da impressora no sistema
529
     * @return string Caso o destino seja S o pdf é retornado como uma string
530
     * @todo Rotina de impressão direta do arquivo pdf criado
531
     */
532
    public function printDACTE($nome = '', $destino = 'I', $printer = '')
0 ignored issues
show
Unused Code introduced by
The parameter $printer 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...
533
    {
534
        $arq = $this->pdf->output($nome, $destino);
535
        if ($destino == 'S') {
536
            //aqui pode entrar a rotina de impressão direta
537
        }
538
        return $arq;
539
    }
540
541
    /**
542
     * cabecalho
543
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
544
     *
545
     * @param  number $x Posição horizontal inicial, canto esquerdo
546
     * @param  number $y Posição vertical inicial, canto superior
547
     * @param  number $pag Número da Página
548
     * @param  number $totPag Total de páginas
549
     * @return number Posição vertical final
550
     */
551
    protected function cabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
552
    {
553
        $oldX = $x;
554
        $oldY = $y;
555
        if ($this->orientacao == 'P') {
556
            $maxW = $this->wPrint;
557
        } else {
558
            if ($pag == 1) {
559
                // primeira página
560
                $maxW = $this->wPrint - $this->wCanhoto;
561
            } else {
562
                // páginas seguintes
563
                $maxW = $this->wPrint;
564
            }
565
        }
566
        //##################################################################
567
        //coluna esquerda identificação do emitente
568
        //$w = round($maxW * 0.42);
569
        $w = round($maxW * 0.32);
570
        if ($this->orientacao == 'P') {
571
            $aFont = array(
0 ignored issues
show
Unused Code introduced by
$aFont is not used, you could remove the assignment.

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

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

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

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

Loading history...
572
                'font' => $this->fontePadrao,
573
                'size' => 6,
574
                'style' => '');
575
        } else {
576
            $aFont = $this->formatNegrito;
0 ignored issues
show
Unused Code introduced by
$aFont is not used, you could remove the assignment.

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

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

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

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

Loading history...
577
        }
578
        $w1 = $w;
0 ignored issues
show
Unused Code introduced by
$w1 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...
579
        $h = 35;
580
        $oldY += $h;
581
        //desenha a caixa
582
        $this->pdf->textBox($x, $y, $w + 2, $h + 1);
583
        // coloca o logo
584
        if (is_file($this->logomarca)) {
585
            $logoInfo = getimagesize($this->logomarca);
586
            //largura da imagem em mm
587
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
588
            //altura da imagem em mm
589
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
590
            if ($this->logoAlign == 'L') {
591
                $nImgW = round($w / 3, 0);
592
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
593
                $xImg = $x + 1;
594
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
595
                //estabelecer posições do texto
596
                $x1 = round($xImg + $nImgW + 1, 0);
597
                $y1 = round($h / 3 + $y, 0);
598
                $tw = round(2 * $w / 3, 0);
599
            } elseif ($this->logoAlign == 'C') {
600
                $nImgH = round($h / 3, 0);
601
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
602
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
603
                $yImg = $y + 3;
604
                $x1 = $x;
605
                $y1 = round($yImg + $nImgH + 1, 0);
606
                $tw = $w;
607
            } elseif ($this->logoAlign == 'R') {
608
                $nImgW = round($w / 3, 0);
609
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
610
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
611
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
612
                $x1 = $x;
613
                $y1 = round($h / 3 + $y, 0);
614
                $tw = round(2 * $w / 3, 0);
615
            }
616
            $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
0 ignored issues
show
Bug introduced by
The variable $xImg 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...
Bug introduced by
The variable $yImg 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...
Bug introduced by
The variable $nImgW 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...
Bug introduced by
The variable $nImgH 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...
617
        } else {
618
            $x1 = $x;
619
            $y1 = round($h / 3 + $y, 0);
620
            $tw = $w;
621
        }
622
        //Nome emitente
623
        $aFont = array(
624
            'font' => $this->fontePadrao,
625
            'size' => 9,
626
            'style' => 'B');
627
        $texto = $this->getTagValue($this->emit, "xNome");
628
        $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The variable $x1 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...
Bug introduced by
The variable $y1 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...
Bug introduced by
The variable $tw 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...
629
        //endereço
630
        $y1 = $y1 + 3;
631
        $aFont = array(
632
            'font' => $this->fontePadrao,
633
            'size' => 7,
634
            'style' => '');
635
        $fone = $this->getTagValue($this->enderEmit, "fone")!=""? $this->formatFone($this->enderEmit):'';
0 ignored issues
show
Documentation introduced by
$this->enderEmit is of type object<DOMNode>, 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...
636
        $lgr = $this->getTagValue($this->enderEmit, "xLgr");
637
        $nro = $this->getTagValue($this->enderEmit, "nro");
638
        $cpl = $this->getTagValue($this->enderEmit, "xCpl");
0 ignored issues
show
Unused Code introduced by
$cpl 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...
639
        $bairro = $this->getTagValue($this->enderEmit, "xBairro");
640
        $CEP = $this->getTagValue($this->enderEmit, "CEP");
641
        $CEP = $this->formatField($CEP, "#####-###");
642
        $mun = $this->getTagValue($this->enderEmit, "xMun");
643
        $UF = $this->getTagValue($this->enderEmit, "UF");
644
        $xPais = $this->getTagValue($this->enderEmit, "xPais");
645
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
646
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
647
            . "\n  Fone/Fax: " . $fone;
648
        $this->pdf->textBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
649
        //CNPJ/CPF IE
650
        $cpfCnpj = $this->formatCNPJCPF($this->emit);
0 ignored issues
show
Documentation introduced by
$this->emit is of type object<DOMNode>, 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...
651
        $ie = $this->getTagValue($this->emit, "IE");
652
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
653
        $this->pdf->textBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
654
        //outra caixa
655
        $h1 = 17.5;
656
        $y1 = $y + $h + 1;
657
        $this->pdf->textBox($x, $y1, $w + 2, $h1);
658
        //TIPO DO CT-E
659
        $texto = 'TIPO DO CTE';
660
        //$wa = 37;
661
        $wa = 34;
662
        $aFont = array(
663
            'font' => $this->fontePadrao,
664
            'size' => 8,
665
            'style' => '');
666
        $this->pdf->textBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
667
        $tpCTe = $this->getTagValue($this->ide, "tpCTe");
668
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
669
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
670
        switch ($tpCTe) {
671
            case '0':
672
                $texto = 'Normal';
673
                break;
674
            case '1':
675
                $texto = 'Complemento de Valores';
676
                break;
677
            case '2':
678
                $texto = 'Anulação de Valores';
679
                break;
680
            case '3':
681
                $texto = 'Substituto';
682
                break;
683
            default:
684
                $texto = 'ERRO' . $tpCTe . $tpServ;
0 ignored issues
show
Bug introduced by
The variable $tpServ seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
685
        }
686
        $aFont = $this->formatNegrito;
687
        $this->pdf->textBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
688
        //TIPO DO SERVIÇO
689
        $texto = 'TIPO DO SERVIÇO';
690
        $wb = 36;
0 ignored issues
show
Unused Code introduced by
$wb 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
        $aFont = array(
692
            'font' => $this->fontePadrao,
693
            'size' => 8,
694
            'style' => '');
695
        $this->pdf->textBox($x + $wa, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
696
        $tpServ = $this->getTagValue($this->ide, "tpServ");
697
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
698
        switch ($tpServ) {
699
            case '0':
700
                $texto = 'Normal';
701
                break;
702
            case '1':
703
                $texto = 'Subcontratação';
704
                break;
705
            case '2':
706
                $texto = 'Redespacho';
707
                break;
708
            case '3':
709
                $texto = 'Redespacho Intermediário';
710
                break;
711
            default:
712
                $texto = 'ERRO' . $tpServ;
713
        }
714
        $aFont = $this->formatNegrito;
715
        $this->pdf->textBox($x + $wa, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
716
        $this->pdf->line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
717
        //TOMADOR DO SERVIÇO
718
        $texto = 'IND.DO CT-E GLOBALIZADO';
719
        $wc = 37;
0 ignored issues
show
Unused Code introduced by
$wc 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...
720
        $y2 = $y1 + 8;
721
        $aFont = array(
722
            'font' => $this->fontePadrao,
723
            'size' => 6,
724
            'style' => '');
725
        $this->pdf->textBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
726
        $this->pdf->line($x, $y1 + 8, $w + 3, $y1 + 8);
727
        $toma = $this->getTagValue($this->ide, "indGlobalizado");
728
        //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4 - Outros
729
        if ($toma==1) {
730
            $aFont = array(
731
            'font' => $this->fontePadrao,
732
            'size' => 11,
733
            'style' => '');
734
            $this->pdf->textBox($x-14.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
735
        } else {
736
            $aFont = array(
737
            'font' => $this->fontePadrao,
738
            'size' => 11,
739
            'style' => '');
740
            $this->pdf->textBox($x+3.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
741
        }
742
        $aFont = $this->formatNegrito;
743
        $this->pdf->line($x+3, $x+71, $x+3, $x+75);
744
        $this->pdf->line($x+8, $x+71, $x+8, $x+75);
745
        $this->pdf->line($x+3, $x+71, $x+8, $x+71);
746
        $this->pdf->line($x+3, $x+75, $x+8, $x+75);
747
        $this->pdf->textBox($x-6, $y2+1.4 + 3, $w * 0.5, $h1, 'SIM', $aFont, 'T', 'C', 0, '', false);
748
        $this->pdf->line($x+18, $x+71, $x+18, $x+75);
749
        $this->pdf->line($x+23, $x+71, $x+23, $x+75);
750
        $this->pdf->line($x+18, $x+71, $x+23, $x+71);
751
        $this->pdf->line($x+18, $x+75, $x+23, $x+75);
752
        $this->pdf->textBox($x+9.8, $y2+1.4 + 3, $w * 0.5, $h1, 'NÃO', $aFont, 'T', 'C', 0, '', false);
753
        //FORMA DE PAGAMENTO
754
        $texto = 'INF.DO CT-E GLOBALIZADO';
755
        $wd = 36;
0 ignored issues
show
Unused Code introduced by
$wd 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...
756
        $aFont = array(
757
            'font' => $this->fontePadrao,
758
            'size' => 8,
759
            'style' => '');
760
        $this->pdf->textBox($x + $wa, $y2-0.5, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
761
        $forma = $this->getTagValue($this->ide, "forPag");
0 ignored issues
show
Unused Code introduced by
$forma 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...
762
        //##################################################################
763
        //coluna direita
764
        $x += $w + 2;
765
        $w = round($maxW * 0.212);
766
        $w1 = $w;
767
        $h = 11;
768
        $this->pdf->textBox($x, $y, $w + 48.5, $h + 1);
769
        $texto = "DACTE";
770
        $aFont = array(
771
            'font' => $this->fontePadrao,
772
            'size' => 10,
773
            'style' => 'B');
774
        $this->pdf->textBox($x + 25, $y + 2, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
775
        $aFont = array(
776
            'font' => $this->fontePadrao,
777
            'size' => 9,
778
            'style' => '');
779
        $texto = "Documento Auxiliar do Conhecimento de Transporte Eletrônico";
780
        $h = 10;
781
        $this->pdf->textBox($x + 5, $y + 6, $w + 40, $h, $texto, $aFont, 'T', 'C', 0, '', false);
782
        $x1 = $x + $w + 2;
783
        $w = round($maxW * 0.22, 0);
784
        $w2 = $w;
785
        $h = 11;
786
        $this->pdf->textBox($x1 + 46.5, $y, $w - 0.5, $h + 1);
787
        $texto = "MODAL";
788
        $aFont = array(
789
            'font' => $this->fontePadrao,
790
            'size' => 8,
791
            'style' => '');
792
        $this->pdf->textBox($x1 + 47, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
793
        switch ($this->modal) {
794
            case '1':
795
                $texto = 'Rodoviário';
796
                break;
797
            case '2':
798
                $texto = 'Aéreo';
799
                break;
800
            case '3':
801
                $texto = 'Aquaviário';
802
                break;
803
            case '4':
804
                $texto = 'Ferroviário';
805
                break;
806
            case '5':
807
                $texto = 'Dutoviário';
808
                break;
809
        }
810
        $aFont = array(
811
            'font' => $this->fontePadrao,
812
            'size' => 10,
813
            'style' => 'B');
814
        $this->pdf->textBox($x1 + 47, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
815
        //outra caixa
816
        $y += 12;
817
        $h = 9;
818
        $w = $w1 + $w2 + 2;
819
        $this->pdf->textBox($x, $y, $w + 0.5, $h + 1);
820
        //modelo
821
        $wa = 12;
822
        $xa = $x;
823
        $texto = 'MODELO';
824
        $aFont = array(
825
            'font' => $this->fontePadrao,
826
            'size' => 8,
827
            'style' => '');
828
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
829
        $texto = $this->getTagValue($this->ide, "mod");
830
        $aFont = $this->formatNegrito;
831
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
832
        $this->pdf->line($x + $wa, $y, $x + $wa, $y + $h + 1);
833
        //serie
834
        $wa = 11;
835
        $xa += $wa;
836
        $texto = 'SÉRIE';
837
        $aFont = array(
838
            'font' => $this->fontePadrao,
839
            'size' => 8,
840
            'style' => '');
841
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
842
        $texto = $this->getTagValue($this->ide, "serie");
843
        $aFont = $this->formatNegrito;
844
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
845
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
846
        //numero
847
        $xa += $wa;
848
        $wa = 14;
849
        $texto = 'NÚMERO';
850
        $aFont = array(
851
            'font' => $this->fontePadrao,
852
            'size' => 8,
853
            'style' => '');
854
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
855
        $texto = $this->getTagValue($this->ide, "nCT");
856
        $aFont = $this->formatNegrito;
857
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
858
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
859
        //folha
860
        $xa += $wa;
861
        $wa = 6;
862
        $texto = 'FL';
863
        $aFont = array(
864
            'font' => $this->fontePadrao,
865
            'size' => 8,
866
            'style' => '');
867
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
868
        //$texto = '1/1';
869
        $texto = $pag."/".$totPag;
870
        $aFont = $this->formatNegrito;
871
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
872
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
873
        //data  hora de emissão
874
        $xa += $wa;
875
        $wa = 28;
876
        $texto = 'DATA E HORA DE EMISSÃO';
877
        $aFont = array(
878
            'font' => $this->fontePadrao,
879
            'size' => 8,
880
            'style' => '');
881
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
882
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
883
            date('d/m/Y H:i:s', $this->convertTime($this->getTagValue($this->ide, "dhEmi"))) : '';
884
        $aFont = $this->formatNegrito;
885
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
886
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
887
        //ISUF
888
        $xa += $wa;
889
        $wa = 30;
890
        $texto = 'INSC.SUF.DO DEST';
891
        $aFont = $this->formatPadrao;
892
        $this->pdf->textBox($xa-5, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
893
        $texto = $this->getTagValue($this->dest, "ISUF");
894
        $aFont = array(
895
            'font' => $this->fontePadrao,
896
            'size' => 7,
897
            'style' => 'B');
898
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
899
        //outra caixa
900
        $y += $h + 1;
901
        $h = 23;
902
        $h1 = 14;
903
        $this->pdf->textBox($x, $y, $w + 0.5, $h1);
904
        //CODIGO DE BARRAS
905
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
906
        $bW = 85;
907
        $bH = 10;
908
        //codigo de barras
909
        $this->pdf->setFillColor(0, 0, 0);
910
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
911
        $this->pdf->textBox($x, $y + $h1, $w + 0.5, $h1 - 6);
912
        $texto = 'CHAVE DE ACESSO';
913
        $aFont = $this->formatPadrao;
914
        $this->pdf->textBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
915
        $aFont = $this->formatNegrito;
916
        $texto = $this->formatField($chave_acesso, $this->formatoChave);
917
        $this->pdf->textBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
918
        $this->pdf->textBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
919
        $texto = "Consulta em http://www.cte.fazenda.gov.br/portal";
920
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
921
            $texto = "";
922
            $this->pdf->setFillColor(0, 0, 0);
923
            if ($this->tpEmis == 5) {
924
                $chaveContingencia = $this->geraChaveAdicCont();
925
                $this->pdf->code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
926
            } else {
927
                $chaveContingencia = $this->getTagValue($this->protCTe, "nProt");
928
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
929
            }
930
            //codigo de barras
931
        }
932
        $aFont = array(
933
            'font' => $this->fontePadrao,
934
            'size' => 8,
935
            'style' => '');
936
        $this->pdf->textBox($x, $y + $h1 + 11, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
937
        //outra caixa
938
        $y += $h + 1;
939
        $h = 8.5;
940
        $wa = $w;
941
        $this->pdf->textBox($x, $y + 7.5, $w + 0.5, $h);
942
        if ($this->cteDPEC()) {
943
            $texto = 'NÚMERO DE REGISTRO DPEC';
944
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
945
            $texto = "DADOS DO CT-E";
946
        } else {
947
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
948
        }
949
        $aFont = $this->formatPadrao;
950
        $this->pdf->textBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
951
        if ($this->cteDPEC()) {
952
            $texto = $this->numero_registro_dpec;
953
        } elseif ($this->tpEmis == 5) {
954
            $chaveContingencia = $this->geraChaveAdicCont();
955
            $aFont = array(
0 ignored issues
show
Unused Code introduced by
$aFont is not used, you could remove the assignment.

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

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

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

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

Loading history...
956
                'font' => $this->fontePadrao,
957
                'size' => 8,
958
                'style' => 'B');
959
            $texto = $this->formatField($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
960
            $cStat = '';
0 ignored issues
show
Unused Code introduced by
$cStat 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...
961
        } else {
962
            $texto = $this->getTagValue($this->protCTe, "nProt") . " - ";
963
            if (!empty($this->protCTe)
964
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
965
            ) {
966
                $texto .= date(
967
                    'd/m/Y   H:i:s',
968
                    $this->convertTime($this->getTagValue($this->protCTe, "dhRecbto"))
969
                );
970
            }
971
            $texto = $this->getTagValue($this->protCTe, "nProt") == '' ? '' : $texto;
972
        }
973
        $aFont = $this->formatNegrito;
974
        $this->pdf->textBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
975
        if ($this->qrCodCTe !== null) {
976
            $this->qrCodeDacte($y-27);
977
            $w = 45;
978
            $x += 92.5;
979
            $this->pdf->textBox($x, $y - 34, $w + 0.5, $h + 41.5);
980
        }
981
        //CFOP
982
        $x = $oldX;
983
        $h = 8.5;
984
        $w = round($maxW * 0.32);
985
        $y1 = $y + 7.5;
986
        $this->pdf->textBox($x, $y1, $w + 2, $h);
987
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
988
        $aFont = array(
989
            'font' => $this->fontePadrao,
990
            'size' => 8,
991
            'style' => '');
992
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
993
        $texto = $this->getTagValue($this->ide, "CFOP") . ' - ' . $this->getTagValue($this->ide, "natOp");
994
        $aFont = $this->formatNegrito;
995
        $this->pdf->textBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
996
        //ORIGEM DA PRESTAÇÃO
997
        $y += $h + 7.5;
998
        $x = $oldX;
999
        $h = 8;
1000
        $w = ($maxW * 0.5);
1001
        $this->pdf->textBox($x, $y, $w + 0.5, $h);
1002
        $texto = 'INÍCIO DA PRESTAÇÃO';
1003
        $aFont = array(
1004
            'font' => $this->fontePadrao,
1005
            'size' => 8,
1006
            'style' => '');
1007
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1008
        $texto = $this->getTagValue($this->ide, "xMunIni") . ' - ' . $this->getTagValue($this->ide, "UFIni");
1009
        $aFont = $this->formatNegrito;
1010
        $this->pdf->textBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1011
        //DESTINO DA PRESTAÇÃO
1012
        $x = $oldX + $w + 1;
1013
        $h = 8;
1014
        $w = $w - 1.3;
1015
        $this->pdf->textBox($x - 0.5, $y, $w + 0.5, $h);
1016
        $texto = 'TÉRMINO DA PRESTAÇÃO';
1017
        $aFont = array(
1018
            'font' => $this->fontePadrao,
1019
            'size' => 8,
1020
            'style' => '');
1021
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1022
        $texto = $this->getTagValue($this->ide, "xMunFim") . ' - ' . $this->getTagValue($this->ide, "UFFim");
1023
        $aFont = $this->formatNegrito;
1024
        $this->pdf->textBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1025
        //#########################################################################
1026
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
1027
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
1028
        //indicar cancelamento
1029
        $cStat = $this->getTagValue($this->cteProc, "cStat");
1030
        if ($cStat == '101' || $cStat == '135' || $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_CANCELADA) {
1031
            //101 Cancelamento
1032
            $x = 10;
1033
            $y = $this->hPrint - 130;
1034
            $h = 25;
1035
            $w = $maxW - (2 * $x);
1036
            $this->pdf->setTextColor(90, 90, 90);
1037
            $texto = "CTe CANCELADO";
1038
            $aFont = array(
1039
                'font' => $this->fontePadrao,
1040
                'size' => 48,
1041
                'style' => 'B');
1042
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1043
            $this->pdf->setTextColor(0, 0, 0);
1044
        }
1045
        $cStat = $this->getTagValue($this->cteProc, "cStat");
1046
        if ($cStat == '110' ||
1047
            $cStat == '301' ||
1048
            $cStat == '302' ||
1049
            $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_DENEGADA
1050
        ) {
1051
            //110 Denegada
1052
            $x = 10;
1053
            $y = $this->hPrint - 130;
1054
            $h = 25;
1055
            $w = $maxW - (2 * $x);
1056
            $this->pdf->setTextColor(90, 90, 90);
1057
            $texto = "CTe USO DENEGADO";
1058
            $aFont = array(
1059
                'font' => $this->fontePadrao,
1060
                'size' => 48,
1061
                'style' => 'B');
1062
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1063
            $y += $h;
1064
            $h = 5;
1065
            $w = $maxW - (2 * $x);
1066
            $texto = "SEM VALOR FISCAL";
1067
            $aFont = array(
1068
                'font' => $this->fontePadrao,
1069
                'size' => 48,
1070
                'style' => 'B');
1071
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1072
            $this->pdf->setTextColor(0, 0, 0);
1073
        }
1074
        //indicar sem valor
1075
        if ($tpAmb != 1 && $this->preVisualizar=='0') { // caso não seja uma DA de produção
1076
            $x = 10;
1077
            if ($this->orientacao == 'P') {
1078
                $y = round($this->hPrint * 2 / 3, 0);
1079
            } else {
1080
                $y = round($this->hPrint / 2, 0);
1081
            }
1082
            $h = 5;
1083
            $w = $maxW - (2 * $x);
1084
            $this->pdf->setTextColor(90, 90, 90);
1085
            $texto = "SEM VALOR FISCAL";
1086
            $aFont = array(
1087
                'font' => $this->fontePadrao,
1088
                'size' => 48,
1089
                'style' => 'B');
1090
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1091
            $aFont = array(
1092
                'font' => $this->fontePadrao,
1093
                'size' => 30,
1094
                'style' => 'B');
1095
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1096
            $this->pdf->textBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1097
            $this->pdf->setTextColor(0, 0, 0);
1098
        } elseif ($this->preVisualizar=='1') { // caso seja uma DA de Pré-Visualização
1099
            $h = 5;
1100
            $w = $maxW - (2 * 10);
1101
            $x = 55;
1102
            $y = 240;
1103
            $this->pdf->setTextColor(255, 100, 100);
1104
            $aFont = array(
1105
                'font' => $this->fontePadrao,
1106
                'size' => 40,
1107
                'style' => 'B');
1108
            $texto = "Pré-visualização";
1109
            $this->pTextBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method pTextBox90() does not seem to exist on object<NFePHP\DA\CTe\Dacte>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1110
            $this->pdf->setTextColor(255, 100, 100);
1111
            $aFont = array(
1112
                'font' => $this->fontePadrao,
1113
                'size' => 41,
1114
                'style' => 'B');
1115
            $texto = "Sem Validade Jurídica";
1116
            $this->pTextBox90($x+20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method pTextBox90() does not seem to exist on object<NFePHP\DA\CTe\Dacte>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1117
            $this->pdf->setTextColor(90, 90, 90);
1118
            $texto = "SEM VALOR FISCAL";
1119
            $aFont = array(
1120
                'font' => $this->fontePadrao,
1121
                'size' => 48,
1122
                'style' => 'B');
1123
            $this->pTextBox90($x+40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method pTextBox90() does not seem to exist on object<NFePHP\DA\CTe\Dacte>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1124
            $this->pdf->setTextColor(0, 0, 0); // voltar a cor default
1125
        } else {
1126
            $x = 10;
1127
            if ($this->orientacao == 'P') {
1128
                $y = round($this->hPrint * 2 / 3, 0);
1129
            } else {
1130
                $y = round($this->hPrint / 2, 0);
1131
            } //fim orientacao
1132
            $h = 5;
1133
            $w = $maxW - (2 * $x);
1134
            $this->pdf->setTextColor(90, 90, 90);
1135
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1136
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->cteDPEC()) {
1137
                //Contingência
1138
                $texto = "DACTE Emitido em Contingência";
1139
                $aFont = array(
1140
                    'font' => $this->fontePadrao,
1141
                    'size' => 48,
1142
                    'style' => 'B');
1143
                $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1144
                $aFont = array(
1145
                    'font' => $this->fontePadrao,
1146
                    'size' => 30,
1147
                    'style' => 'B');
1148
                $texto = "devido à problemas técnicos";
1149
                $this->pdf->textBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1150
            } else {
1151
                if (!isset($this->protCTe)) {
1152
                    if (!$this->cteDPEC()) {
1153
                        $texto = "SEM VALOR FISCAL";
1154
                        $aFont = array(
1155
                            'font' => $this->fontePadrao,
1156
                            'size' => 48,
1157
                            'style' => 'B');
1158
                        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1159
                    }
1160
                    $aFont = array(
1161
                        'font' => $this->fontePadrao,
1162
                        'size' => 30,
1163
                        'style' => 'B');
1164
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1165
                    if (!$this->cteDPEC()) {
1166
                        $this->pdf->textBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1167
                    } else {
1168
                        $this->pdf->textBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1169
                    }
1170
                } //fim cteProc
1171
                if ($this->tpEmis == 4) {
1172
                    //DPEC
1173
                    $x = 10;
1174
                    $y = $this->hPrint - 130;
1175
                    $h = 25;
1176
                    $w = $maxW - (2 * $x);
1177
                    $this->pdf->setTextColor(200, 200, 200); // 90,90,90 é muito escuro
1178
                    $texto = "DACTE impresso em contingência -\n"
1179
                        . "DPEC regularmente recebido pela Receita\n"
1180
                        . "Federal do Brasil";
1181
                    $aFont = array(
1182
                        'font' => $this->fontePadrao,
1183
                        'size' => 48,
1184
                        'style' => 'B');
1185
                    $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1186
                    $this->pdf->setTextColor(0, 0, 0);
1187
                }
1188
            } //fim tpEmis
1189
            $this->pdf->setTextColor(0, 0, 0);
1190
        }
1191
        return $oldY;
1192
    }
1193
1194
    /**
1195
     * rodapeDACTE
1196
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1197
     *
1198
     * @param number $xInic Posição horizontal canto esquerdo
0 ignored issues
show
Bug introduced by
There is no parameter named $xInic. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
1199
     * @param number $yFinal Posição vertical final para impressão
0 ignored issues
show
Bug introduced by
There is no parameter named $yFinal. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
1200
     */
1201
    protected function rodape($x, $y)
1202
    {
1203
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1204
        $w = $this->wPrint - 4;
1205
        $aFont = array(
1206
            'font' => $this->fontePadrao,
1207
            'size' => 6,
1208
            'style' => '');
1209
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1210
        $texto = 'Desenvolvido por '.$this->nomeDesenvolvedor . ' - '. $this->siteDesenvolvedor;
1211
        $aFont = array(
1212
            'font' => $this->fontePadrao,
1213
            'size' => 6,
1214
            'style' => '');
1215
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, $this->siteDesenvolvedor);
1216
    }
1217
1218
    /**
1219
     * remetente
1220
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1221
     *
1222
     * @param  number $x Posição horizontal canto esquerdo
1223
     * @param  number $y Posição vertical canto superior
1224
     * @return number Posição vertical final
1225
     */
1226
    protected function remetente($x = 0, $y = 0)
1227
    {
1228
        $oldX = $x;
1229
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
1230
        if ($this->orientacao == 'P') {
1231
            $maxW = $this->wPrint;
1232
        } else {
1233
            $maxW = $this->wPrint - $this->wCanhoto;
1234
        }
1235
        $w = $maxW * 0.5 + 0.5;
1236
        $h = 19;
1237
        $x1 = $x + 16;
1238
        $texto = 'REMETENTE';
1239
        $aFont = $this->formatPadrao;
1240
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1241
        $aFont = $this->formatNegrito;
1242
        $texto = $this->getTagValue($this->rem, "xNome");
1243
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1244
        $y += 3;
1245
        $texto = 'ENDEREÇO';
1246
        $aFont = $this->formatPadrao;
1247
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1248
        $aFont = $this->formatNegrito;
1249
        $texto = $this->getTagValue($this->enderReme, "xLgr") . ',';
1250
        $texto .= $this->getTagValue($this->enderReme, "nro");
1251
        $texto .= ($this->getTagValue($this->enderReme, "xCpl") != "") ?
1252
            ' - ' . $this->getTagValue($this->enderReme, "xCpl") : '';
1253
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1254
        $y += 3;
1255
        $texto = $this->getTagValue($this->enderReme, "xBairro");
1256
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1257
        $y += 3;
1258
        $texto = 'MUNICÍPIO';
1259
        $aFont = $this->formatPadrao;
1260
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1261
        $texto = $this->getTagValue($this->enderReme, "xMun") . ' - ';
1262
        $texto .= $this->getTagValue($this->enderReme, "UF");
1263
        $aFont = $this->formatNegrito;
1264
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1265
        $x = $w - 18;
1266
        $texto = 'CEP';
1267
        $aFont = $this->formatPadrao;
1268
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1269
        $texto = $this->formatField($this->getTagValue($this->enderReme, "CEP"), "#####-###");
1270
        $aFont = $this->formatNegrito;
1271
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1272
        $x = $oldX;
1273
        $y += 3;
1274
        $texto = 'CNPJ/CPF';
1275
        $aFont = $this->formatPadrao;
1276
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1277
        $cpfCnpj = $this->formatCNPJCPF($this->rem);
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, 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...
1278
        $aFont = $this->formatNegrito;
1279
        $this->pdf->textBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1280
        $x = $w - 45;
1281
        $texto = 'INSCRIÇÃO ESTADUAL';
1282
        $aFont = $this->formatPadrao;
1283
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1284
        $texto = $this->getTagValue($this->rem, "IE");
1285
        $aFont = $this->formatNegrito;
1286
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1287
        $x = $oldX;
1288
        $y += 3;
1289
        $texto = 'PAÍS';
1290
        $aFont = $this->formatPadrao;
1291
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1292
        $texto = $this->getTagValue($this->rem, "xPais") != "" ?
1293
            $this->getTagValue($this->rem, "xPais") : 'BRASIL';
1294
        $aFont = $this->formatNegrito;
1295
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1296
        $x = $w - 25;
1297
        $texto = 'FONE';
1298
        $aFont = $this->formatPadrao;
1299
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1300
        //$texto = $this->formatFone($this->rem);
1301
        $texto = $this->getTagValue($this->rem, "fone")!=""? $this->formatFone($this->rem):'';
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, 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...
1302
        $aFont = $this->formatNegrito;
1303
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1304
    }
1305
1306
    /**
1307
     * destinatario
1308
     * Monta o campo com os dados do destinatário na DACTE.
1309
     *
1310
     * @param  number $x Posição horizontal canto esquerdo
1311
     * @param  number $y Posição vertical canto superior
1312
     * @return number Posição vertical final
1313
     */
1314
    protected function destinatario($x = 0, $y = 0)
1315
    {
1316
        $oldX = $x;
1317
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
1318
        if ($this->orientacao == 'P') {
1319
            $maxW = $this->wPrint;
1320
        } else {
1321
            $maxW = $this->wPrint - $this->wCanhoto;
1322
        }
1323
        $w = ($maxW * 0.5) - 0.7;
1324
        $h = 19;
1325
        $x1 = $x + 19;
1326
        $texto = 'DESTINATÁRIO';
1327
        $aFont = $this->formatPadrao;
1328
        $this->pdf->textBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1329
        $aFont = $this->formatNegrito;
1330
        $texto = $this->getTagValue($this->dest, "xNome");
1331
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1332
        $y += 3;
1333
        $texto = 'ENDEREÇO';
1334
        $aFont = $this->formatPadrao;
1335
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1336
        $aFont = $this->formatNegrito;
1337
        $texto = $this->getTagValue($this->enderDest, "xLgr") . ',';
1338
        $texto .= $this->getTagValue($this->enderDest, "nro");
1339
        $texto .= $this->getTagValue($this->enderDest, "xCpl") != "" ?
1340
            ' - ' . $this->getTagValue($this->enderDest, "xCpl") : '';
1341
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1342
        $y += 3;
1343
        $texto = $this->getTagValue($this->enderDest, "xBairro");
1344
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1345
        $y += 3;
1346
        $texto = 'MUNICÍPIO';
1347
        $aFont = $this->formatPadrao;
1348
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1349
        $texto = $this->getTagValue($this->enderDest, "xMun") . ' - ';
1350
        $texto .= $this->getTagValue($this->enderDest, "UF");
1351
        $aFont = $this->formatNegrito;
1352
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1353
        $x = $w - 19 + $oldX;
1354
        $texto = 'CEP';
1355
        $aFont = $this->formatPadrao;
1356
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1357
        $texto = $this->formatField($this->getTagValue($this->enderDest, "CEP"), "#####-###");
1358
        $aFont = $this->formatNegrito;
1359
        $this->pdf->textBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1360
        $x = $oldX;
1361
        $y += 3;
1362
        $texto = 'CNPJ/CPF';
1363
        $aFont = $this->formatPadrao;
1364
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1365
        $cpfCnpj = $this->formatCNPJCPF($this->dest);
0 ignored issues
show
Documentation introduced by
$this->dest is of type object<DOMNode>, 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...
1366
        $aFont = $this->formatNegrito;
1367
        $this->pdf->textBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1368
        $x = $w - 47.5 + $oldX;
1369
        $texto = 'INSCRIÇÃO ESTADUAL';
1370
        $aFont = $this->formatPadrao;
1371
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1372
        $texto = $this->getTagValue($this->dest, "IE");
1373
        $aFont = $this->formatNegrito;
1374
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1375
        $x = $oldX;
1376
        $y += 3;
1377
        $texto = 'PAÍS';
1378
        $aFont = $this->formatPadrao;
1379
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1380
        $texto = $this->getTagValue($this->dest, "xPais");
1381
        $aFont = $this->formatNegrito;
1382
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1383
        $x = $w - 27 + $oldX;
1384
        $texto = 'FONE';
1385
        $aFont = $this->formatPadrao;
1386
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1387
        //$texto = $this->formatFone($this->dest);
1388
        $texto = $this->getTagValue($this->dest, "fone")!=""? $this->formatFone($this->dest):'';
0 ignored issues
show
Documentation introduced by
$this->dest is of type object<DOMNode>, 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...
1389
        $aFont = $this->formatNegrito;
1390
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1391
    }
1392
1393
    /**
1394
     * expedidor
1395
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1396
     *
1397
     * @param  number $x Posição horizontal canto esquerdo
1398
     * @param  number $y Posição vertical canto superior
1399
     * @return number Posição vertical final
1400
     */
1401
    protected function expedidor($x = 0, $y = 0)
1402
    {
1403
        $oldX = $x;
1404
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
1405
        if ($this->orientacao == 'P') {
1406
            $maxW = $this->wPrint;
1407
        } else {
1408
            $maxW = $this->wPrint - $this->wCanhoto;
1409
        }
1410
        $w = $maxW * 0.5 + 0.5;
1411
        $h = 19;
1412
        $x1 = $x + 16;
1413
        $texto = 'EXPEDIDOR';
1414
        $aFont = $this->formatPadrao;
1415
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1416
        $aFont = $this->formatNegrito;
1417
        $texto = $this->getTagValue($this->exped, "xNome");
1418
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1419
        $y += 3;
1420
        $texto = 'ENDEREÇO';
1421
        $aFont = $this->formatPadrao;
1422
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1423
        $aFont = $this->formatNegrito;
1424
        if (isset($this->enderExped)) {
1425
            $texto = $this->getTagValue($this->enderExped, "xLgr") . ', ';
1426
            $texto .= $this->getTagValue($this->enderExped, "nro");
1427
            $texto .= $this->getTagValue($this->enderExped, "xCpl") != "" ?
1428
                ' - ' . $this->getTagValue($this->enderExped, "xCpl") :
1429
                '';
1430
        } else {
1431
            $texto = '';
1432
        }
1433
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1434
        $y += 3;
1435
        $texto = $this->getTagValue($this->enderExped, "xBairro");
0 ignored issues
show
Bug introduced by
It seems like $this->enderExped can be null; however, getTagValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1436
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1437
        $y += 3;
1438
        $texto = 'MUNICÍPIO';
1439
        $aFont = $this->formatPadrao;
1440
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1441
        if (isset($this->enderExped)) {
1442
            $texto = $this->getTagValue($this->enderExped, "xMun") . ' - ';
1443
            $texto .= $this->getTagValue($this->enderExped, "UF");
1444
        } else {
1445
            $texto = '';
1446
        }
1447
        $aFont = $this->formatNegrito;
1448
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1449
        $x = $w - 18;
1450
        $texto = 'CEP';
1451
        $aFont = $this->formatPadrao;
1452
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1453
        $texto = $this->formatField($this->getTagValue($this->enderExped, "CEP"), "#####-###");
0 ignored issues
show
Bug introduced by
It seems like $this->enderExped can be null; however, getTagValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1454
        $aFont = $this->formatNegrito;
1455
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1456
        $x = $oldX;
1457
        $y += 3;
1458
        $texto = 'CNPJ/CPF';
1459
        $aFont = $this->formatPadrao;
1460
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1461
        $cpfCnpj = $this->formatCNPJCPF($this->exped);
0 ignored issues
show
Documentation introduced by
$this->exped is of type object<DOMNode>, 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...
1462
        $aFont = $this->formatNegrito;
1463
        $this->pdf->textBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1464
        $x = $w - 45;
1465
        $texto = 'INSCRIÇÃO ESTADUAL';
1466
        $aFont = $this->formatPadrao;
1467
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1468
        $texto = $this->getTagValue($this->exped, "IE");
1469
        $aFont = $this->formatNegrito;
1470
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1471
        $x = $oldX;
1472
        $y += 3;
1473
        $texto = 'PAÍS';
1474
        $aFont = $this->formatPadrao;
1475
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1476
        $texto = $this->getTagValue($this->exped, "xPais");
1477
        $aFont = $this->formatNegrito;
1478
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1479
        $x = $w - 25;
1480
        $texto = 'FONE';
1481
        $aFont = $this->formatPadrao;
1482
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1483
        if (isset($this->exped)) {
1484
            $texto = $this->getTagValue($this->exped, "fone")!=""? $this->formatFone($this->exped):'';
0 ignored issues
show
Documentation introduced by
$this->exped is of type object<DOMNode>, 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...
1485
            $aFont = $this->formatNegrito;
1486
            $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1487
        }
1488
    }
1489
1490
    /**
1491
     * recebedor
1492
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1493
     *
1494
     * @param  number $x Posição horizontal canto esquerdo
1495
     * @param  number $y Posição vertical canto superior
1496
     * @return number Posição vertical final
1497
     */
1498
    protected function recebedor($x = 0, $y = 0)
1499
    {
1500
        $oldX = $x;
1501
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
1502
        if ($this->orientacao == 'P') {
1503
            $maxW = $this->wPrint;
1504
        } else {
1505
            $maxW = $this->wPrint - $this->wCanhoto;
1506
        }
1507
        $w = ($maxW * 0.5) - 0.7;
1508
        $h = 19;
1509
        $x1 = $x + 19;
1510
        $texto = 'RECEBEDOR';
1511
        $aFont = $this->formatPadrao;
1512
        $this->pdf->textBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1513
        $aFont = $this->formatNegrito;
1514
        $texto = $this->getTagValue($this->receb, "xNome");
1515
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1516
        $y += 3;
1517
        $texto = 'ENDEREÇO';
1518
        $aFont = $this->formatPadrao;
1519
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1520
        $aFont = $this->formatNegrito;
1521
        if (isset($this->enderReceb)) {
1522
            $texto = $this->getTagValue($this->enderReceb, "xLgr") . ', ';
1523
            $texto .= $this->getTagValue($this->enderReceb, "nro");
1524
            $texto .= ($this->getTagValue($this->enderReceb, "xCpl") != "") ?
1525
                ' - ' . $this->getTagValue($this->enderReceb, "xCpl") :
1526
                '';
1527
        } else {
1528
            $texto = '';
1529
        }
1530
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1531
        $y += 3;
1532
        $texto = $this->getTagValue($this->enderReceb, "xBairro");
0 ignored issues
show
Bug introduced by
It seems like $this->enderReceb can be null; however, getTagValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1533
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1534
        $y += 3;
1535
        $texto = 'MUNICÍPIO';
1536
        $aFont = $this->formatPadrao;
1537
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1538
        if (isset($this->enderReceb)) {
1539
            $texto = $this->getTagValue($this->enderReceb, "xMun") . ' - ';
1540
            $texto .= $this->getTagValue($this->enderReceb, "UF");
1541
        } else {
1542
            $texto = '';
1543
        }
1544
        $aFont = $this->formatNegrito;
1545
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1546
        $x = $w - 19 + $oldX;
1547
        $texto = 'CEP';
1548
        $aFont = $this->formatPadrao;
1549
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1550
        $texto = $this->formatField($this->getTagValue($this->enderReceb, "CEP"), "#####-###");
0 ignored issues
show
Bug introduced by
It seems like $this->enderReceb can be null; however, getTagValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1551
        $aFont = $this->formatNegrito;
1552
        $this->pdf->textBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1553
        $x = $oldX;
1554
        $y += 3;
1555
        $texto = 'CNPJ/CPF';
1556
        $aFont = $this->formatPadrao;
1557
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1558
        $texto = $this->formatCNPJCPF($this->receb);
0 ignored issues
show
Documentation introduced by
$this->receb is of type object<DOMNode>, 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...
1559
        $aFont = $this->formatNegrito;
1560
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1561
        $x = $w - 47 + $oldX;
1562
        $texto = 'INSCRIÇÃO ESTADUAL';
1563
        $aFont = $this->formatPadrao;
1564
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1565
        $texto = $this->getTagValue($this->receb, "IE");
1566
        $aFont = $this->formatNegrito;
1567
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1568
        $x = $oldX;
1569
        $y += 3;
1570
        $texto = 'PAÍS';
1571
        $aFont = $this->formatPadrao;
1572
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1573
        $texto = $this->getTagValue($this->receb, "xPais");
1574
        $aFont = $this->formatNegrito;
1575
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1576
        $x = $w - 27 + $oldX;
1577
        $texto = 'FONE';
1578
        $aFont = $this->formatPadrao;
1579
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1580
        if (isset($this->receb)) {
1581
            $texto = $this->getTagValue($this->receb, "fone")!=""? $this->formatFone($this->receb):'';
0 ignored issues
show
Documentation introduced by
$this->receb is of type object<DOMNode>, 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...
1582
            $aFont = $this->formatNegrito;
1583
            $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1584
        }
1585
    }
1586
1587
    /**
1588
     * tomador
1589
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1590
     *
1591
     * @param  number $x Posição horizontal canto esquerdo
1592
     * @param  number $y Posição vertical canto superior
1593
     * @return number Posição vertical final
1594
     */
1595
    protected function tomador($x = 0, $y = 0)
1596
    {
1597
        $oldX = $x;
1598
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
1599
        if ($this->orientacao == 'P') {
1600
            $maxW = $this->wPrint;
1601
        } else {
1602
            $maxW = $this->wPrint - $this->wCanhoto;
1603
        }
1604
        $w = $maxW;
1605
        $h = 10;
1606
        $texto = 'TOMADOR DO SERVIÇO';
1607
        $aFont = $this->formatPadrao;
1608
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1609
        $aFont = $this->formatNegrito;
1610
        $texto = $this->getTagValue($this->toma, "xNome");
1611
        $this->pdf->textBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1612
        $x = $maxW * 0.60;
1613
        $texto = 'MUNICÍPIO';
1614
        $aFont = $this->formatPadrao;
1615
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1616
        $texto = $this->getTagValue($this->toma, "xMun");
1617
        $aFont = $this->formatNegrito;
1618
        $this->pdf->textBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1619
        $x = $maxW * 0.85;
1620
        $texto = 'UF';
1621
        $aFont = $this->formatPadrao;
1622
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1623
        $texto = $this->getTagValue($this->toma, "UF");
1624
        $aFont = $this->formatNegrito;
1625
        $this->pdf->textBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1626
        $x = $w - 18;
1627
        $texto = 'CEP';
1628
        $aFont = $this->formatPadrao;
1629
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1630
        $texto = $this->formatField($this->getTagValue($this->toma, "CEP"), "#####-###");
1631
        $aFont = $this->formatNegrito;
1632
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1633
        $y += 3;
1634
        $x = $oldX;
1635
        $texto = 'ENDEREÇO';
1636
        $aFont = $this->formatPadrao;
1637
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1638
        $aFont = $this->formatNegrito;
1639
        $texto = $this->getTagValue($this->toma, "xLgr") . ',';
1640
        $texto .= $this->getTagValue($this->toma, "nro");
1641
        $texto .= ($this->getTagValue($this->toma, "xCpl") != "") ?
1642
            ' - ' . $this->getTagValue($this->toma, "xCpl") : '';
1643
        $texto .= ' - ' . $this->getTagValue($this->toma, "xBairro");
1644
        $this->pdf->textBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1645
        $y += 3;
1646
        $texto = 'CNPJ/CPF';
1647
        $aFont = $this->formatPadrao;
1648
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1649
        $texto = $this->formatCNPJCPF($this->toma);
1650
        $aFont = $this->formatNegrito;
1651
        $this->pdf->textBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1652
        $x = $x + 65;
1653
        $texto = 'INSCRIÇÃO ESTADUAL';
1654
        $aFont = $this->formatPadrao;
1655
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1656
        $texto = $this->getTagValue($this->toma, "IE");
1657
        $aFont = $this->formatNegrito;
1658
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1659
        $x = $w * 0.75;
1660
        $texto = 'PAÍS';
1661
        $aFont = $this->formatPadrao;
1662
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1663
        $texto = $this->getTagValue($this->toma, "xPais") != "" ?
1664
            $this->getTagValue($this->toma, "xPais") : 'BRASIL';
1665
        $aFont = $this->formatNegrito;
1666
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1667
        $x = $w - 27;
1668
        $texto = 'FONE';
1669
        $aFont = $this->formatPadrao;
1670
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1671
        $texto = $this->getTagValue($this->toma, "fone")!=""? $this->formatFone($this->toma):'';
1672
        $aFont = $this->formatNegrito;
1673
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1674
    }
1675
1676
    /**
1677
     * descricaoCarga
1678
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1679
     *
1680
     * @param  number $x Posição horizontal canto esquerdo
1681
     * @param  number $y Posição vertical canto superior
1682
     * @return number Posição vertical final
1683
     */
1684
    protected function descricaoCarga($x = 0, $y = 0)
1685
    {
1686
        $oldX = $x;
1687
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
1688
        if ($this->orientacao == 'P') {
1689
            $maxW = $this->wPrint;
1690
        } else {
1691
            $maxW = $this->wPrint - $this->wCanhoto;
1692
        }
1693
        $w = $maxW;
1694
        $h = 17;
1695
        $texto = 'PRODUTO PREDOMINANTE';
1696
        $aFont = array(
1697
            'font' => $this->fontePadrao,
1698
            'size' => 6,
1699
            'style' => '');
1700
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1701
        $texto = $this->getTagValue($this->infCarga, "proPred");
1702
        $aFont = $this->formatNegrito;
1703
        $this->pdf->textBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1704
        $x = $w * 0.56;
1705
        $this->pdf->line($x, $y, $x, $y + 8);
1706
        $aFont = $this->formatPadrao;
1707
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1708
        $this->pdf->textBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1709
        $texto = $this->getTagValue($this->infCarga, "xOutCat");
1710
        $aFont = $this->formatNegrito;
1711
        $this->pdf->textBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1712
        $x = $w * 0.8;
1713
        $this->pdf->line($x, $y, $x, $y + 8);
1714
        $aFont = $this->formatPadrao;
1715
        $texto = 'VALOR TOTAL DA CARGA';
1716
        $this->pdf->textBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1717
        $texto = $this->getTagValue($this->infCarga, "vCarga") == "" ?
1718
            $this->getTagValue($this->infCarga, "vMerc") : $this->getTagValue($this->infCarga, "vCarga");
1719
        $texto = number_format($texto, 2, ",", ".");
1720
        $aFont = $this->formatNegrito;
1721
        $this->pdf->textBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1722
        $y += 8;
1723
        $x = $oldX;
1724
        $this->pdf->line($x, $y, $w + 1, $y);
1725
        //Identifica código da unidade
1726
        //01 = KG (QUILOS)
1727
        $qCarga = 0;
1728
        foreach ($this->infQ as $infQ) {
1729
            if ($this->getTagValue($infQ, "cUnid") == '01') {
1730
                $qCarga += (float) $this->getTagValue($infQ, "qCarga");
1731
            }
1732
        }
1733
        $texto = 'PESO BRUTO (KG)';
1734
        $aFont = array(
1735
            'font' => $this->fontePadrao,
1736
            'size' => 5,
1737
            'style' => '');
1738
        $this->pdf->textBox($x+8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1739
        $texto = number_format($qCarga, 3, ",", ".");
1740
        $aFont = array(
1741
            'font' => $this->fontePadrao,
1742
            'size' => 7,
1743
            'style' => 'B');
1744
        $this->pdf->textBox($x+2, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1745
        $x = $w * 0.12;
1746
        $this->pdf->line($x+13.5, $y, $x+13.5, $y + 9);
1747
        $texto = 'PESO BASE CÁLCULO (KG)';
1748
        $aFont = array(
1749
            'font' => $this->fontePadrao,
1750
            'size' => 5,
1751
            'style' => '');
1752
        $this->pdf->textBox($x+20, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1753
        $texto = number_format($qCarga, 3, ",", ".");
1754
        $aFont = array(
1755
            'font' => $this->fontePadrao,
1756
            'size' => 7,
1757
            'style' => 'B');
1758
        $this->pdf->textBox($x+17, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1759
        $x = $w * 0.24;
1760
        $this->pdf->line($x+25, $y, $x+25, $y + 9);
1761
        $texto = 'PESO AFERIDO (KG)';
1762
        $aFont = array(
1763
            'font' => $this->fontePadrao,
1764
            'size' => 5,
1765
            'style' => '');
1766
        $this->pdf->textBox($x+35, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1767
        $texto = number_format($qCarga, 3, ",", ".");
1768
        $aFont = array(
1769
            'font' => $this->fontePadrao,
1770
            'size' => 7,
1771
            'style' => 'B');
1772
        $this->pdf->textBox($x+28, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1773
        $x = $w * 0.36;
1774
        $this->pdf->line($x+41.3, $y, $x+41.3, $y + 9);
1775
        $texto = 'CUBAGEM(M3)';
1776
        $aFont = $this->formatPadrao;
1777
        $this->pdf->textBox($x+60, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1778
        $qCarga = 0;
1779
        foreach ($this->infQ as $infQ) {
1780
            if ($this->getTagValue($infQ, "cUnid") == '00') {
1781
                $qCarga += (float) $this->getTagValue($infQ, "qCarga");
1782
            }
1783
        }
1784
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1785
        $aFont = array(
1786
            'font' => $this->fontePadrao,
1787
            'size' => 7,
1788
            'style' => 'B');
1789
        $this->pdf->textBox($x+50, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1790
        $x = $w * 0.45;
1791
        //$this->pdf->line($x+37, $y, $x+37, $y + 9);
1792
        $texto = 'QTDE(VOL)';
1793
        $aFont = $this->formatPadrao;
1794
        $this->pdf->textBox($x+85, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1795
        $qCarga = 0;
1796
        foreach ($this->infQ as $infQ) {
1797
            if ($this->getTagValue($infQ, "cUnid") == '03') {
1798
                $qCarga += (float) $this->getTagValue($infQ, "qCarga");
1799
            }
1800
        }
1801
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1802
        $aFont = array(
1803
            'font' => $this->fontePadrao,
1804
            'size' => 7,
1805
            'style' => 'B');
1806
        $this->pdf->textBox($x+85, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1807
        $x = $w * 0.53;
1808
        $this->pdf->line($x+56, $y, $x+56, $y + 9);
1809
        /*$texto = 'NOME DA SEGURADORA';
1810
        $aFont = $this->formatPadrao;
1811
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1812
        $texto = $this->getTagValue($this->seg, "xSeg");
1813
        $aFont = array(
1814
            'font' => $this->fontePadrao,
1815
            'size' => 7,
1816
            'style' => 'B');
1817
        $this->pdf->textBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1818
        $y += 3;
1819
        $this->pdf->line($x, $y, $w + 1, $y);
1820
        $texto = 'RESPONSÁVEL';
1821
        $aFont = $this->formatPadrao;
1822
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1823
        $texto = $this->respSeg;
1824
        $aFont = array(
1825
            'font' => $this->fontePadrao,
1826
            'size' => 7,
1827
            'style' => 'B');
1828
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1829
        $x = $w * 0.68;
1830
        $this->pdf->line($x, $y, $x, $y + 6);
1831
        $texto = 'NÚMERO DA APOLICE';
1832
        $aFont = $this->formatPadrao;
1833
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1834
        $texto = $this->getTagValue($this->seg, "nApol");
1835
        $aFont = array(
1836
            'font' => $this->fontePadrao,
1837
            'size' => 7,
1838
            'style' => 'B');
1839
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1840
        $x = $w * 0.85;
1841
        $this->pdf->line($x, $y, $x, $y + 6);
1842
        $texto = 'NÚMERO DA AVERBAÇÃO';
1843
        $aFont = $this->formatPadrao;
1844
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1845
        $texto = $this->getTagValue($this->seg, "nAver");
1846
        $aFont = array(
1847
            'font' => $this->fontePadrao,
1848
            'size' => 7,
1849
            'style' => 'B');
1850
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');*/
1851
    }
1852
1853
    /**
1854
     * compValorServ
1855
     * Monta o campo com os componentes da prestação de serviços.
1856
     *
1857
     * @param  number $x Posição horizontal canto esquerdo
1858
     * @param  number $y Posição vertical canto superior
1859
     * @return number Posição vertical final
1860
     */
1861
    protected function compValorServ($x = 0, $y = 0)
1862
    {
1863
        $oldX = $x;
1864
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
1865
        if ($this->orientacao == 'P') {
1866
            $maxW = $this->wPrint;
1867
        } else {
1868
            $maxW = $this->wPrint - $this->wCanhoto;
1869
        }
1870
        $w = $maxW;
1871
        $h = 25;
1872
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1873
        $aFont = $this->formatPadrao;
1874
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1875
        $y += 3.4;
1876
        $this->pdf->line($x, $y, $w + 1, $y);
1877
        $texto = 'NOME';
1878
        $aFont = $this->formatPadrao;
1879
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1880
        $yIniDados = $y;
1881
        $x = $w * 0.14;
1882
        $texto = 'VALOR';
1883
        $aFont = $this->formatPadrao;
1884
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1885
        $x = $w * 0.28;
1886
        $this->pdf->line($x, $y, $x, $y + 21.5);
1887
        $texto = 'NOME';
1888
        $aFont = $this->formatPadrao;
1889
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1890
        $x = $w * 0.42;
1891
        $texto = 'VALOR';
1892
        $aFont = $this->formatPadrao;
1893
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1894
        $x = $w * 0.56;
1895
        $this->pdf->line($x, $y, $x, $y + 21.5);
1896
        $texto = 'NOME';
1897
        $aFont = $this->formatPadrao;
1898
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1899
        $x = $w * 0.70;
1900
        $texto = 'VALOR';
1901
        $aFont = $this->formatPadrao;
1902
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1903
        $x = $w * 0.86;
1904
        $this->pdf->line($x, $y, $x, $y + 21.5);
1905
        $y += 1;
1906
        $texto = 'VALOR TOTAL DO SERVIÇO';
1907
        $aFont = $this->formatPadrao;
1908
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1909
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
1910
        $aFont = array(
1911
            'font' => $this->fontePadrao,
1912
            'size' => 9,
1913
            'style' => 'B');
1914
        $this->pdf->textBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1915
        $y += 10;
1916
        $this->pdf->line($x, $y, $w + 1, $y);
1917
        $y += 1;
1918
        $texto = 'VALOR A RECEBER';
1919
        $aFont = $this->formatPadrao;
1920
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1921
        $texto = number_format($this->getTagValue($this->vPrest, "vRec"), 2, ",", ".");
1922
        $aFont = array(
1923
            'font' => $this->fontePadrao,
1924
            'size' => 9,
1925
            'style' => 'B');
1926
        $this->pdf->textBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1927
        $auxX = $oldX;
1928
        $yIniDados += 4;
1929
        foreach ($this->Comp as $k => $d) {
1930
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1931
            $valor = number_format(
1932
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1933
                2,
1934
                ",",
1935
                "."
1936
            );
1937
            if ($auxX > $w * 0.60) {
1938
                $yIniDados = $yIniDados + 4;
1939
                $auxX = $oldX;
1940
            }
1941
            $texto = $nome;
1942
            $aFont = $this->formatPadrao;
1943
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1944
            $auxX += $w * 0.14;
1945
            $texto = $valor;
1946
            $aFont = $this->formatPadrao;
1947
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1948
            $auxX += $w * 0.14;
1949
        }
1950
    }
1951
1952
    /**
1953
     * impostos
1954
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1955
     *
1956
     * @param  number $x Posição horizontal canto esquerdo
1957
     * @param  number $y Posição vertical canto superior
1958
     * @return number Posição vertical final
1959
     */
1960
    protected function impostos($x = 0, $y = 0)
1961
    {
1962
        $oldX = $x;
1963
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
1964
        if ($this->orientacao == 'P') {
1965
            $maxW = $this->wPrint;
1966
        } else {
1967
            $maxW = $this->wPrint - $this->wCanhoto;
1968
        }
1969
        $w = $maxW;
1970
        $h = 13;
1971
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
1972
        $aFont = $this->formatPadrao;
1973
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1974
        $y += 3.4;
1975
        $this->pdf->line($x, $y, $w + 1, $y);
1976
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
1977
        $aFont = $this->formatPadrao;
1978
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1979
        $x += $w * 0.26;
1980
        $this->pdf->line($x, $y, $x, $y + 9.5);
1981
        $texto = 'BASE DE CALCULO';
1982
        $aFont = $this->formatPadrao;
1983
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1984
        $wCol02=0.15;
1985
        $x += $w * $wCol02;
1986
        $this->pdf->line($x, $y, $x, $y + 9.5);
1987
        $texto = 'ALÍQ ICMS';
1988
        $aFont = $this->formatPadrao;
1989
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1990
        $x += $w * $wCol02;
1991
        $this->pdf->line($x, $y, $x, $y + 9.5);
1992
        $texto = 'VALOR ICMS';
1993
        $aFont = $this->formatPadrao;
1994
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1995
        $x += $w * $wCol02;
1996
        $this->pdf->line($x, $y, $x, $y + 9.5);
1997
        $texto = '% RED. BC ICMS';
1998
        $aFont = $this->formatPadrao;
1999
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2000
        $x += $w * $wCol02;
2001
        $this->pdf->line($x, $y, $x, $y + 9.5);
2002
        $texto = 'VALOR ICMS ST';
2003
        $aFont = $this->formatPadrao;
2004
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2005
        /*$x += $w * 0.14;
2006
        $this->pdf->line($x, $y, $x, $y + 9.5);
2007
        $texto = 'ICMS ST';
2008
        $aFont = $this->formatPadrao;
2009
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2010
         * */
2011
        $x = $oldX;
2012
        $y = $y + 4;
2013
        $texto = $this->getTagValue($this->ICMS, "CST");
2014
        switch ($texto) {
2015
            case '00':
2016
                $texto = "00 - Tributação normal ICMS";
2017
                break;
2018
            case '20':
2019
                $texto = "20 - Tributação com BC reduzida do ICMS";
2020
                break;
2021
            case '40':
2022
                $texto = "40 - ICMS isenção";
2023
                break;
2024
            case '41':
2025
                $texto = "41 - ICMS não tributada";
2026
                break;
2027
            case '51':
2028
                $texto = "51 - ICMS diferido";
2029
                break;
2030
            case '60':
2031
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
2032
                break;
2033
            case '90':
2034
                if ($this->ICMSOutraUF) {
2035
                    $texto = "90 - ICMS Outra UF";
2036
                } else {
2037
                    $texto = "90 - ICMS Outros";
2038
                }
2039
                break;
2040
        }
2041
        if ($this->getTagValue($this->ICMS, "CST") == '60') {
2042
            $aFont = $this->formatNegrito;
2043
            $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2044
            $x += $w * 0.26;
2045
            $texto = !empty($this->ICMS->getElementsByTagName("vBCSTRet")->item(0)->nodeValue) ?
2046
                number_format($this->getTagValue($this->ICMS, "vBCSTRet"), 2, ",", ".") : (
2047
                    !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
2048
                    number_format($this->getTagValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
2049
                );
2050
            $aFont = $this->formatNegrito;
2051
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2052
            $x += $w * $wCol02;
2053
            $texto = !empty($this->ICMS->getElementsByTagName("pICMSSTRet")->item(0)->nodeValue) ?
2054
                number_format($this->getTagValue($this->ICMS, "pICMSSTRet"), 2, ",", ".") : (
2055
                    !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
2056
                    number_format($this->getTagValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
2057
                );
2058
            $aFont = $this->formatNegrito;
2059
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2060
            $x += $w * $wCol02;
2061
            $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2062
                number_format($this->getTagValue($this->ICMS, "vICMS"), 2, ",", ".") : (
2063
                    !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
2064
                    number_format($this->getTagValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
2065
                );
2066
            $aFont = $this->formatNegrito;
2067
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2068
            $x += $w * $wCol02;
2069
            $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2070
                number_format($this->getTagValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
2071
                    !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
2072
                number_format($this->getTagValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
2073
                );
2074
            $aFont = $this->formatNegrito;
2075
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2076
            $x += $w * $wCol02;
2077
            $texto = !empty($this->ICMS->getElementsByTagName("vICMSSTRet")->item(0)->nodeValue) ?
2078
                number_format($this->getTagValue($this->ICMS, "vICMSSTRet"), 2, ",", ".") : '';
2079
            $aFont = $this->formatNegrito;
2080
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2081
        } else {
2082
            $texto = $this->getTagValue($this->ICMSSN, "indSN") == 1 ? 'Simples Nacional' : $texto;
2083
            $aFont = $this->formatNegrito;
2084
            $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2085
            $x += $w * 0.26;
2086
            $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2087
                number_format($this->getTagValue($this->ICMS, "vBC"), 2, ",", ".") : (
2088
                    !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
2089
                    number_format($this->getTagValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
2090
                );
2091
            $aFont = $this->formatNegrito;
2092
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2093
            $x += $w * $wCol02;
2094
            $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2095
                number_format($this->getTagValue($this->ICMS, "pICMS"), 2, ",", ".") : (
2096
                    !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
2097
                    number_format($this->getTagValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
2098
                );
2099
            $aFont = $this->formatNegrito;
2100
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2101
            $x += $w * $wCol02;
2102
            $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2103
                number_format($this->getTagValue($this->ICMS, "vICMS"), 2, ",", ".") : (
2104
                    !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
2105
                    number_format($this->getTagValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
2106
                );
2107
            $aFont = $this->formatNegrito;
2108
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2109
            $x += $w * $wCol02;
2110
            $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2111
                number_format($this->getTagValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
2112
                    !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
2113
                number_format($this->getTagValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
2114
                );
2115
            $aFont = $this->formatNegrito;
2116
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2117
            $x += $w * $wCol02;
2118
            $texto = !empty($this->ICMS->getElementsByTagName("vICMSSTRet")->item(0)->nodeValue) ?
2119
                number_format($this->getTagValue($this->ICMS, "vICMSSTRet"), 2, ",", ".") : '';
2120
            $aFont = $this->formatNegrito;
2121
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2122
        }
2123
        /*$x += $w * 0.14;
2124
        $texto = '';
2125
        $aFont = $this->formatNegrito;
2126
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2127
    }
2128
2129
    /**
2130
     * geraChaveAdicCont
2131
     *
2132
     * @return string chave
2133
     */
2134
    protected function geraChaveAdicCont()
2135
    {
2136
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2137
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
2138
        $forma = "%02d%d%s%014d%01d%01d%02d";
2139
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2140
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2141
        $CNPJ = substr($CNPJ, -14);
2142
        $vCT = number_format($this->getTagValue($this->vPrest, "vRec"), 2, "", "") * 100;
2143
        $ICMS_CST = $this->getTagValue($this->ICMS, "CST");
2144
        switch ($ICMS_CST) {
2145
            case '00':
2146
            case '20':
2147
                $ICMSp = '1';
2148
                $ICMSs = '2';
2149
                break;
2150
            case '40':
2151
            case '41':
2152
            case '51':
2153
            case '90':
2154
                $ICMSp = '2';
2155
                $ICMSs = '2';
2156
                break;
2157
            case '60':
2158
                $ICMSp = '2';
2159
                $ICMSs = '1';
2160
                break;
2161
        }
2162
        $dd = $this->ide->getElementsByTagName('dhEmi')->item(0)->nodeValue;
2163
        $rpos = strrpos($dd, '-');
2164
        $dd = substr($dd, $rpos + 1);
2165
        $chave = sprintf($forma, $cUF, $this->tpEmis, $CNPJ, $vCT, $ICMSp, $ICMSs, $dd);
0 ignored issues
show
Bug introduced by
The variable $ICMSp 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...
Bug introduced by
The variable $ICMSs 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...
2166
        $chave = $chave . $this->pModulo11($chave);
0 ignored issues
show
Bug introduced by
The method pModulo11() does not exist on NFePHP\DA\CTe\Dacte. Did you maybe mean modulo11()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
2167
        return $chave;
2168
    }
2169
2170
    /**
2171
     * docOrig
2172
     * Monta o campo com os documentos originarios.
2173
     *
2174
     * @param  number $x Posição horizontal canto esquerdo
2175
     * @param  number $y Posição vertical canto superior
2176
     * @return number Posição vertical final
2177
     */
2178
    protected function docOrig($x = 0, $y = 0)
2179
    {
2180
        $oldX = $x;
2181
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
2182
        if ($this->orientacao == 'P') {
2183
            $maxW = $this->wPrint;
2184
        } else {
2185
            $maxW = $this->wPrint - $this->wCanhoto;
2186
        }
2187
        $w = $maxW;
2188
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2189
        if ($this->modal == '1') {
2190
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2191
            // ou combinação veicular, e por viagem
2192
            $h = $this->lota == 1 ? 35 : 53;
2193
        } elseif ($this->modal == '2') {
2194
            $h = 53;
2195
        } elseif ($this->modal == '3') {
2196
            $h = 37.6;
2197
        } else {
2198
            $h = 35;
2199
        }
2200
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2201
        $aFont = $this->formatPadrao;
2202
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2203
        $descr1 = 'TIPO DOC';
2204
        $descr2 = 'CNPJ/CHAVE/OBS';
2205
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2206
        $y += 3.4;
2207
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
2208
        $texto = $descr1;
2209
        $aFont = $this->formatPadrao;
2210
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2211
        $yIniDados = $y;
2212
        $x += $w * 0.07;
2213
        $texto = $descr2;
2214
        $aFont = $this->formatPadrao;
2215
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2216
        $x += $w * 0.28;
2217
        $texto = $descr3;
2218
        $aFont = $this->formatPadrao;
2219
        $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2220
        $x += $w * 0.14;
2221
        if ($this->modal == '1') {
2222
            if ($this->lota == 1) {
2223
                $this->pdf->line($x, $y, $x, $y + 31.5); // TESTE
2224
            } else {
2225
                $this->pdf->line($x, $y, $x, $y + 49.5); // TESTE
2226
            }
2227
        } elseif ($this->modal == '2') {
2228
            $this->pdf->line($x, $y, $x, $y + 49.5);
2229
        } elseif ($this->modal == '3') {
2230
            $this->pdf->line($x, $y, $x, $y + 34.1);
2231
        } else {
2232
            $this->pdf->line($x, $y, $x, $y + 21.5);
2233
        }
2234
        $texto = $descr1;
2235
        $aFont = $this->formatPadrao;
2236
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2237
        $x += $w * 0.08;
2238
        $texto = $descr2;
2239
        $aFont = $this->formatPadrao;
2240
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2241
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2242
        $texto = $descr3;
2243
        $aFont = $this->formatPadrao;
2244
        $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2245
        $auxX = $oldX;
2246
        $yIniDados += 3;
2247
        foreach ($this->infNF as $k => $d) {
2248
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2249
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2250
            $cnpj = $this->formatCNPJCPF($this->rem);
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, 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...
2251
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2252
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2253
            if ($auxX > $w * 0.90) {
2254
                $yIniDados = $yIniDados + 3;
2255
                $auxX = $oldX;
2256
            }
2257
            $texto = $tp;
2258
            $aFont = array(
2259
                'font' => $this->fontePadrao,
2260
                'size' => 8,
2261
                'style' => '');
2262
            //$this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2263
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2264
            //$auxX += $w * 0.09;
2265
            $auxX += $w * 0.07;
2266
            $texto = $cnpj;
2267
            $aFont = array(
2268
                'font' => $this->fontePadrao,
2269
                'size' => 8,
2270
                'style' => '');
2271
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2272
            $auxX += $w * 0.28;
2273
            $texto = $doc;
2274
            $aFont = array(
2275
                'font' => $this->fontePadrao,
2276
                'size' => 8,
2277
                'style' => '');
2278
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2279
            $auxX += $w * 0.15;
2280
        }
2281
        foreach ($this->infNFe as $k => $d) {
2282
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2283
            $this->arrayNFe[] = $chaveNFe;
2284
        }
2285
        $qtdeNFe = 1;
2286
        if (count($this->arrayNFe) >15) {
2287
            $this->flagDocOrigContinuacao = 1;
2288
            $qtdeNFe = count($this->arrayNFe);
2289
        }
2290
//        $totPag = count($this->arrayNFe) > 15 ? '2' : '1';
2291
        switch ($qtdeNFe) {
2292
            default:
2293
                $this->totPag = 1;
2294
            case ($qtdeNFe >= 1044):
2295
                $this->totPag = 11;
2296
                break;
2297
            case ($qtdeNFe > 928):
2298
                $this->totPag = 10;
2299
                break;
2300
            case ($qtdeNFe > 812):
2301
                $this->totPag = 9;
2302
                break;
2303
            case ($qtdeNFe > 696):
2304
                $this->totPag = 8;
2305
                break;
2306
            case ($qtdeNFe > 580):
2307
                $this->totPag = 7;
2308
                break;
2309
            case ($qtdeNFe > 464):
2310
                $this->totPag = 6;
2311
                break;
2312
            case ($qtdeNFe > 348):
2313
                $this->totPag = 5;
2314
                break;
2315
            case ($qtdeNFe > 232):
2316
                $this->totPag = 4;
2317
                break;
2318
            case ($qtdeNFe > 116):
2319
                $this->totPag = 3;
2320
                break;
2321
            case ($qtdeNFe > 16):
2322
                $this->totPag = 2;
2323
                break;
2324
            case ($qtdeNFe <= 16):
2325
                $this->totPag = 1;
2326
                break;
2327
        }
2328
        //$r = $this->cabecalho(1, 1, '1', $this->totPag);
2329
        $contador = 0;
2330
        while ($contador < count($this->arrayNFe)) {
2331
            if ($contador == 15) {
2332
                break;
2333
            }
2334
            $tp = 'NF-e';
2335
            $chaveNFe = $this->arrayNFe[$contador];
2336
            $numNFe = substr($chaveNFe, 25, 9);
2337
            $serieNFe = substr($chaveNFe, 22, 3);
2338
            $doc = $serieNFe . '/' . $numNFe;
2339
            if ($auxX > $w * 0.90) {
2340
                $yIniDados = $yIniDados + 3.5;
2341
                $auxX = $oldX;
2342
            }
2343
            $texto = $tp;
2344
            $aFont = array(
2345
                'font' => $this->fontePadrao,
2346
                'size' => 7,
2347
                'style' => '');
2348
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2349
            $auxX += $w * 0.07;
2350
            $texto = $chaveNFe;
2351
            $aFont = array(
2352
                'font' => $this->fontePadrao,
2353
                'size' => 7,
2354
                'style' => '');
2355
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2356
            $auxX += $w * 0.28;
2357
            $texto = $doc;
2358
            $aFont = array(
2359
                'font' => $this->fontePadrao,
2360
                'size' => 7,
2361
                'style' => '');
2362
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2363
            $auxX += $w * 0.15;
2364
            $contador++;
2365
        }
2366
        foreach ($this->infOutros as $k => $d) {
2367
            $temp = $this->infOutros->item($k);
2368
            $tpDoc = $this->getTagValue($temp, "tpDoc");
2369
            $descOutros = $this->getTagValue($temp, "descOutros");
2370
            $nDoc = $this->getTagValue($temp, "nDoc");
2371
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
0 ignored issues
show
Bug introduced by
The method pSimpleGetDate() does not exist on NFePHP\DA\CTe\Dacte. Did you maybe mean simpleGetDate()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
2372
            $vDocFisc = $this->getTagValue($temp, "vDocFisc", "Valor: ");
2373
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
0 ignored issues
show
Bug introduced by
The method pSimpleGetDate() does not exist on NFePHP\DA\CTe\Dacte. Did you maybe mean simpleGetDate()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
2374
            switch ($tpDoc) {
2375
                case "00":
2376
                    $tpDoc = "00 - Declaração";
2377
                    break;
2378
                case "10":
2379
                    $tpDoc = "10 - Dutoviário";
2380
                    break;
2381
                case "99":
2382
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2383
                    break;
2384
                default:
2385
                    break;
2386
            }
2387
            $numeroDocumento = $nDoc;
0 ignored issues
show
Unused Code introduced by
$numeroDocumento 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...
2388
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2389
            if ($auxX > $w * 0.90) {
2390
                $yIniDados = $yIniDados + 4;
2391
                $auxX = $oldX;
2392
            }
2393
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2394
            $auxX += $w * 0.09;
2395
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2396
            $auxX += $w * 0.28;
2397
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2398
            $auxX += $w * 0.14;
2399
        }
2400
        foreach ($this->idDocAntEle as $k => $d) {
2401
            $tp = 'CT-e';
2402
            $chaveCTe = $this->idDocAntEle->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The method item cannot be called on $this->idDocAntEle (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
2403
            $numCTe = substr($chaveCTe, 25, 9);
2404
            $serieCTe = substr($chaveCTe, 22, 3);
2405
            $doc = $serieCTe . '/' . $numCTe;
2406
            if ($auxX > $w * 0.90) {
2407
                $yIniDados = $yIniDados + 4;
2408
                $auxX = $oldX;
2409
            }
2410
            $texto = $tp;
2411
            $aFont = array(
2412
                'font' => $this->fontePadrao,
2413
                'size' => 8,
2414
                'style' => '');
2415
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2416
            $auxX += $w * 0.09;
2417
            $texto = $chaveCTe;
2418
            $aFont = array(
2419
                'font' => $this->fontePadrao,
2420
                'size' => 8,
2421
                'style' => '');
2422
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2423
            $auxX += $w * 0.28;
2424
            $texto = $doc;
2425
            $aFont = array(
2426
                'font' => $this->fontePadrao,
2427
                'size' => 8,
2428
                'style' => '');
2429
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2430
            $auxX += $w * 0.14;
2431
        }
2432
    }
2433
2434
    /**
2435
     * docOrigContinuacao
2436
     * Monta o campo com os documentos originarios.
2437
     *
2438
     * @param  number $x Posição horizontal canto esquerdo
2439
     * @param  number $y Posição vertical canto superior
2440
     * @return number Posição vertical final
2441
     */
2442
    protected function docOrigContinuacao($x = 0, $y = 0)
2443
    {
2444
        $x2 = $x;
2445
        $y2 = $y;
2446
        $contador = 16;
2447
        for ($i = 2; $i <= $this->totPag; $i++) {
2448
            $x = $x2;
2449
            $y = $y2;
2450
            $this->pdf->AddPage($this->orientacao, $this->papel);
2451
            $r = $this->cabecalho(1, 1, $i, $this->totPag);
0 ignored issues
show
Unused Code introduced by
$r 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...
2452
            $oldX = $x;
2453
            $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
2454
            if ($this->orientacao == 'P') {
2455
                $maxW = $this->wPrint;
2456
            } else {
2457
                $maxW = $this->wPrint - $this->wCanhoto;
2458
            }
2459
            $w = $maxW;
2460
            //$h = 6; // de sub-titulo
2461
            //$h = 6 + 3; // de altura do texto (primeira linha
2462
            //$h = 9 + 3.5 ;// segunda linha
2463
            //$h = 9 + 3.5+ 3.5 ;// segunda linha
2464
            $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9;
2465
            if (count($this->arrayNFe)%2 !=0) {
2466
                $h = $h+3.5;
2467
            } // Caso tenha apenas 1 registro na ultima linha
2468
            $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2469
            $aFont = $this->formatPadrao;
2470
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2471
            $descr1 = 'TIPO DOC';
2472
            $descr2 = 'CNPJ/CHAVE/OBS';
2473
            $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2474
            $y += 3.4;
2475
            $this->pdf->line($x, $y, $w + 1, $y);
2476
            $texto = $descr1;
2477
            $aFont = $this->formatPadrao;
2478
            $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2479
            $yIniDados = $y;
2480
            $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2481
            $texto = $descr2;
2482
            $aFont = $this->formatPadrao;
2483
            $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2484
            $x += $w * 0.28;
2485
            $texto = $descr3;
2486
            $aFont = $this->formatPadrao;
2487
            $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2488
            $x += $w * 0.14;
2489
            if ($this->modal == '1') {
2490
                if ($this->lota == 1) {
2491
                    $this->pdf->line($x, $y, $x, $y + 31.5);
2492
                } else {
2493
                    $this->pdf->line($x, $y, $x, $y + 49.5);
2494
                }
2495
            } elseif ($this->modal == '2') {
2496
                $this->pdf->line($x, $y, $x, $y + 49.5);
2497
            } elseif ($this->modal == '3') {
2498
                $this->pdf->line($x, $y, $x, $y + 34.1);
2499
            } else {
2500
                $this->pdf->line($x, $y, $x, $y + 21.5);
2501
            }
2502
            $texto = $descr1;
2503
            $aFont = $this->formatPadrao;
2504
            $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2505
            $x += $w * 0.08;
2506
            $texto = $descr2;
2507
            $aFont = $this->formatPadrao;
2508
            $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2509
            $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2510
            $texto = $descr3;
2511
            $aFont = $this->formatPadrao;
2512
            $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2513
            $auxX = $oldX;
2514
            $yIniDados += 3;
2515
            while ($contador < (count($this->arrayNFe))) {
2516
                if ($contador%(116*($i-1)) == 0) {
2517
//                    $contador++;
2518
                    break;
2519
                }
2520
                $tp = 'NF-e';
2521
                $chaveNFe = $this->arrayNFe[$contador];
2522
                $numNFe = substr($chaveNFe, 25, 9);
2523
                $serieNFe = substr($chaveNFe, 22, 3);
2524
                $doc = $serieNFe . '/' . $numNFe;
2525
                if ($auxX > $w * 0.90) {
2526
                    $yIniDados = $yIniDados + 3.5;
2527
                    $auxX = $oldX;
2528
                }
2529
                $texto = $tp;
2530
                $aFont = array(
2531
                    'font' => $this->fontePadrao,
2532
                    'size' => 7,
2533
                    'style' => '');
2534
                $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2535
                $auxX += $w * 0.07;
2536
                $texto = $chaveNFe;
2537
                $aFont = array(
2538
                    'font' => $this->fontePadrao,
2539
                    'size' => 7,
2540
                    'style' => '');
2541
                $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2542
                $auxX += $w * 0.28;
2543
                $texto = $doc;
2544
                $aFont = array(
2545
                    'font' => $this->fontePadrao,
2546
                    'size' => 7,
2547
                    'style' => '');
2548
                $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2549
                $auxX += $w * 0.15;
2550
                $contador++;
2551
            }
2552
        }
2553
    }
2554
2555
    /**
2556
     * docCompl
2557
     * Monta o campo com os dados do remetente na DACTE.
2558
     *
2559
     * @param number $x Posição horizontal canto esquerdo
2560
     * @param number $y Posição vertical canto superior
2561
     * @return number Posição vertical final
2562
     */
2563
    protected function docCompl($x = 0, $y = 0)
2564
    {
2565
        $oldX = $x;
2566
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
2567
        if ($this->orientacao == 'P') {
2568
            $maxW = $this->wPrint;
2569
        } else {
2570
            $maxW = $this->wPrint - $this->wCanhoto;
2571
        }
2572
        $w = $maxW;
2573
        $h = 80;
2574
        if ($this->tpCTe == 1) {
2575
            $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2576
            $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2577
            $descr2 = 'VALOR COMPLEMENTADO';
2578
        } else {
2579
            $texto = 'DETALHAMENTO DO CT-E ANULADO';
2580
            $descr1 = 'CHAVE DO CT-E ANULADO';
2581
            $descr2 = 'VALOR ANULADO';
2582
        }
2583
        $aFont = $this->formatPadrao;
2584
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2585
        $y += 3.4;
2586
        $this->pdf->line($x, $y, $w + 1, $y);
2587
        $texto = $descr1;
2588
        $aFont = $this->formatPadrao;
2589
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2590
        $yIniDados = $y;
2591
        $x += $w * 0.37;
2592
        $texto = $descr2;
2593
        $aFont = $this->formatPadrao;
2594
        $this->pdf->textBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2595
        $x += $w * 0.13;
2596
        $this->pdf->line($x, $y, $x, $y + 76.5);
2597
        $texto = $descr1;
2598
        $aFont = $this->formatPadrao;
2599
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2600
        $x += $w * 0.3;
2601
        $texto = $descr2;
2602
        $aFont = $this->formatPadrao;
2603
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2604
        $auxX = $oldX;
2605
        $yIniDados += 4;
2606
        if ($auxX > $w * 0.90) {
2607
            $yIniDados = $yIniDados + 4;
2608
            $auxX = $oldX;
2609
        }
2610
        $texto = $this->chaveCTeRef;
2611
        $aFont = array(
2612
            'font' => $this->fontePadrao,
2613
            'size' => 8,
2614
            'style' => '');
2615
        $this->pdf->textBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2616
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
2617
        $aFont = array(
2618
            'font' => $this->fontePadrao,
2619
            'size' => 8,
2620
            'style' => '');
2621
        $this->pdf->textBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2622
    }
2623
2624
    /**
2625
     * observacao
2626
     * Monta o campo com os dados do remetente na DACTE.
2627
     *
2628
     * @param  number $x Posição horizontal canto esquerdo
2629
     * @param  number $y Posição vertical canto superior
2630
     * @return number Posição vertical final
2631
     */
2632
    protected function observacao($x = 0, $y = 0)
2633
    {
2634
        $oldX = $x;
2635
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
2636
        if ($this->orientacao == 'P') {
2637
            $maxW = $this->wPrint;
2638
        } else {
2639
            $maxW = $this->wPrint - $this->wCanhoto;
2640
        }
2641
        $w = $maxW;
2642
        //$h = 18;
2643
        $h = 18.8;
2644
        $texto = 'OBSERVAÇÕES';
2645
        $aFont = $this->formatPadrao;
2646
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2647
        $y += 3.4;
2648
        $this->pdf->line($x, $y, $w + 1, $y);
2649
        $auxX = $oldX;
0 ignored issues
show
Unused Code introduced by
$auxX 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...
2650
        $yIniDados = $y;
0 ignored issues
show
Unused Code introduced by
$yIniDados 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...
2651
        $texto = '';
2652
        foreach ($this->compl as $k => $d) {
2653
            $xObs = $this->getTagValue($this->compl->item($k), "xObs");
2654
            $texto .= $xObs;
2655
        }
2656
        $textoObs = explode("Motorista:", $texto);
2657
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: ".$textoObs[1]: '';
2658
        $texto .= $this->getTagValue($this->imp, "infAdFisco", "\r\n");
2659
        $aFont = array(
2660
            'font' => $this->fontePadrao,
2661
            'size' => 7.5,
2662
            'style' => '');
2663
        $this->pdf->textBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
2664
        $this->pdf->textBox($x, $y+11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
2665
    }
2666
2667
    /**
2668
     * modalRod
2669
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2670
     *
2671
     * @param  number $x Posição horizontal canto esquerdo
2672
     * @param  number $y Posição vertical canto superior
2673
     * @return number Posição vertical final
2674
     */
2675
    protected function modalRod($x = 0, $y = 0)
2676
    {
2677
        $oldX = $x;
0 ignored issues
show
Unused Code introduced by
$oldX 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...
2678
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
2679
        $lotacao = '';
0 ignored issues
show
Unused Code introduced by
$lotacao 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...
2680
        if ($this->orientacao == 'P') {
2681
            $maxW = $this->wPrint;
2682
        } else {
2683
            $maxW = $this->wPrint - $this->wCanhoto;
2684
        }
2685
        $w = $maxW;
2686
        $h = 3;
2687
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
2688
        $aFont = $this->formatPadrao;
2689
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2690
        if ($this->lota == 1) {
2691
            $this->pdf->line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2692
        }
2693
        $y += 3.4;
2694
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA DE CIMA
2695
        $texto = 'RNTRC DA EMPRESA';
2696
        $aFont = $this->formatPadrao;
2697
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2698
        $texto = $this->getTagValue($this->rodo, "RNTRC");
2699
        $aFont = $this->formatNegrito;
2700
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2701
        $x += $w * 0.23;
2702
        $this->pdf->line($x-20, $y, $x-20, $y + 6); // LINHA A FRENTE DA RNTRC DA EMPRESA
2703
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2704
        $aFont = $this->formatPadrao;
2705
        $this->pdf->textBox($x-20, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2706
    }
2707
2708
    /**
2709
     * modalAereo
2710
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2711
     *
2712
     * @param  number $x Posição horizontal canto esquerdo
2713
     * @param  number $y Posição vertical canto superior
2714
     * @return number Posição vertical final
2715
     */
2716
    protected function modalAereo($x = 0, $y = 0)
2717
    {
2718
        $oldX = $x;
0 ignored issues
show
Unused Code introduced by
$oldX 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...
2719
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
2720
        $lotacao = '';
0 ignored issues
show
Unused Code introduced by
$lotacao 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...
2721
        if ($this->orientacao == 'P') {
2722
            $maxW = $this->wPrint;
2723
        } else {
2724
            $maxW = $this->wPrint - $this->wCanhoto;
2725
        }
2726
        $w = $maxW;
2727
        $h = 3;
2728
        $texto = 'DADOS ESPECÍFICOS DO MODAL AÉREO';
2729
        $aFont = $this->formatPadrao;
2730
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2731
        $y += 3.4;
2732
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA DE CIMA
2733
        $texto = 'NÚMERO OPERACIONAL DO CONHECIMENTO AÉREO';
2734
        $aFont = $this->formatPadrao;
2735
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2736
        $texto = 'CLASSE DA TARIFA';
2737
        $aFont = $this->formatPadrao;
2738
        $this->pdf->textBox($x+50, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2739
        $texto = 'CÓDIGO DA TARIFA';
2740
        $aFont = $this->formatPadrao;
2741
        $this->pdf->textBox($x+80, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2742
        $texto = 'VALOR DA TARIFA';
2743
        $aFont = $this->formatPadrao;
2744
        $this->pdf->textBox($x+110, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2745
        $texto = $this->getTagValue($this->aereo, "nOCA");
2746
        $aFont = $this->formatNegrito;
2747
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2748
        $x += $w * 0.23;
2749
        $this->pdf->line($x, $y, $x, $y + 6); // LINHA APÓS NÚMERO OP. DO CT-E AEREO
2750
        $texto = $this->getTagValue($this->aereo, "CL");
2751
        $aFont = $this->formatNegrito;
2752
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2753
        $x += 30;
2754
        $this->pdf->line($x, $y, $x, $y + 6); // LINHA APÓS CLASSE DA TARIFA
2755
        $texto = $this->getTagValue($this->aereo, "cTar");
2756
        $aFont = $this->formatNegrito;
2757
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2758
        $x += 30;
2759
        $this->pdf->line($x, $y, $x, $y + 6); // LINHA APÓS COD DA TARIFA
2760
        $texto = $this->getTagValue($this->aereo, "vTar");
2761
        $aFont = $this->formatNegrito;
2762
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2763
    }
2764
2765
    /**
2766
     * modalAquaviario
2767
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2768
     *
2769
     * @param  number $x Posição horizontal canto esquerdo
2770
     * @param  number $y Posição vertical canto superior
2771
     * @return number Posição vertical final
2772
     */
2773
    protected function modalAquaviario($x = 0, $y = 0)
2774
    {
2775
        $oldX = $x;
0 ignored issues
show
Unused Code introduced by
$oldX 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...
2776
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
2777
        if ($this->orientacao == 'P') {
2778
            $maxW = $this->wPrint;
2779
        } else {
2780
            $maxW = $this->wPrint - $this->wCanhoto;
2781
        }
2782
        $w = $maxW;
2783
        $h = 8.5;
2784
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2785
        $aFont = $this->formatPadrao;
2786
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2787
        $y += 3.4;
2788
        $this->pdf->line($x, $y, $w + 1, $y);
2789
        $texto = 'PORTO DE EMBARQUE';
2790
        $aFont = $this->formatPadrao;
2791
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2792
        $texto = $this->getTagValue($this->aquav, "prtEmb");
2793
        $aFont = $this->formatNegrito;
2794
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2795
        $x += $w * 0.50;
2796
        $this->pdf->line($x, $y, $x, $y + 7.7);
2797
        $texto = 'PORTO DE DESTINO';
2798
        $aFont = $this->formatPadrao;
2799
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2800
        $texto = $this->getTagValue($this->aquav, "prtDest");
2801
        $aFont = $this->formatNegrito;
2802
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2803
        $y += 8;
2804
        $this->pdf->line(208, $y, 1, $y);
2805
        $x = 1;
2806
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2807
        $aFont = $this->formatPadrao;
2808
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2809
        $texto = $this->getTagValue($this->aquav, "xNavio");
2810
        $aFont = $this->formatNegrito;
2811
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2812
        $x += $w * 0.50;
2813
        $this->pdf->line($x, $y, $x, $y + 7.7);
2814
        $texto = 'VR DA B. DE CALC. AFRMM';
2815
        $aFont = $this->formatPadrao;
2816
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2817
        $texto = $this->getTagValue($this->aquav, "vPrest");
2818
        $aFont = $this->formatNegrito;
2819
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2820
        $x += $w * 0.17;
2821
        $this->pdf->line($x, $y, $x, $y + 7.7);
2822
        $texto = 'VALOR DO AFRMM';
2823
        $aFont = $this->formatPadrao;
2824
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2825
        $texto = $this->getTagValue($this->aquav, "vAFRMM");
2826
        $aFont = $this->formatNegrito;
2827
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2828
        $x += $w * 0.12;
2829
        $this->pdf->line($x, $y, $x, $y + 7.7);
2830
        $texto = 'TIPO DE NAVEGAÇÃO';
2831
        $aFont = $this->formatPadrao;
2832
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2833
        $texto = $this->getTagValue($this->aquav, "tpNav");
2834
        switch ($texto) {
2835
            case '0':
2836
                $texto = 'INTERIOR';
2837
                break;
2838
            case '1':
2839
                $texto = 'CABOTAGEM';
2840
                break;
2841
        }
2842
        $aFont = $this->formatNegrito;
2843
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2844
        $x += $w * 0.14;
2845
        $this->pdf->line($x, $y, $x, $y + 7.7);
2846
        $texto = 'DIREÇÃO';
2847
        $aFont = $this->formatPadrao;
2848
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2849
        $texto = $this->getTagValue($this->aquav, "direc");
2850
        switch ($texto) {
2851
            case 'N':
2852
                $texto = 'NORTE';
2853
                break;
2854
            case 'L':
2855
                $texto = 'LESTE';
2856
                break;
2857
            case 'S':
2858
                $texto = 'SUL';
2859
                break;
2860
            case 'O':
2861
                $texto = 'OESTE';
2862
                break;
2863
        }
2864
        $aFont = $this->formatNegrito;
2865
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2866
        $y += 8;
2867
        $this->pdf->line(208, $y, 1, $y);
2868
        $x = 1;
2869
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2870
        $aFont = $this->formatPadrao;
2871
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2872
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2873
            $texto = $this->infNF
2874
                ->item(0)
2875
                ->getElementsByTagName('infUnidCarga')
2876
                ->item(0)
2877
                ->getElementsByTagName('idUnidCarga')
2878
                ->item(0)->nodeValue;
2879
        } elseif ($this->infNFe->item(0) !== null
2880
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2881
        ) {
2882
            $texto = $this->infNFe
2883
                ->item(0)
2884
                ->getElementsByTagName('infUnidCarga')
2885
                ->item(0)
2886
                ->getElementsByTagName('idUnidCarga')
2887
                ->item(0)
2888
                ->nodeValue;
2889
        } elseif ($this->infOutros->item(0) !== null
2890
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2891
        ) {
2892
            $texto = $this->infOutros
2893
                ->item(0)
2894
                ->getElementsByTagName('infUnidCarga')
2895
                ->item(0)
2896
                ->getElementsByTagName('idUnidCarga')
2897
                ->item(0)
2898
                ->nodeValue;
2899
        } else {
2900
            $texto = '';
2901
        }
2902
        $aFont = $this->formatNegrito;
2903
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2904
        $x += $w * 0.50;
2905
        $this->pdf->line($x, $y, $x, $y + 7.7);
2906
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2907
        $aFont = $this->formatPadrao;
2908
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2909
        $texto = '';
2910
        if ($this->getTagValue($this->aquav, "balsa") !== '') {
2911
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2912
                if ($k == 0) {
2913
                    $texto = $this->aquav
2914
                        ->getElementsByTagName('balsa')
2915
                        ->item($k)
2916
                        ->getElementsByTagName('xBalsa')
2917
                        ->item(0)
2918
                        ->nodeValue;
2919
                } else {
2920
                    $texto = $texto
2921
                        . ' / '
2922
                        . $this->aquav
2923
                            ->getElementsByTagName('balsa')
2924
                            ->item($k)
2925
                            ->getElementsByTagName('xBalsa')
2926
                            ->item(0)
2927
                            ->nodeValue;
2928
                }
2929
            }
2930
        }
2931
        $aFont = $this->formatNegrito;
2932
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2933
    }
2934
2935
    /**
2936
     * modalFerr
2937
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2938
     *
2939
     * @param  number $x Posição horizontal canto esquerdo
2940
     * @param  number $y Posição vertical canto superior
2941
     * @return number Posição vertical final
2942
     */
2943
    protected function modalFerr($x = 0, $y = 0)
2944
    {
2945
        $oldX = $x;
0 ignored issues
show
Unused Code introduced by
$oldX 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...
2946
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
2947
        if ($this->orientacao == 'P') {
2948
            $maxW = $this->wPrint;
2949
        } else {
2950
            $maxW = $this->wPrint - $this->wCanhoto;
2951
        }
2952
        $w = $maxW;
2953
        $h = 19.6;
2954
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2955
        $aFont = $this->formatPadrao;
2956
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2957
        $y += 3.4;
2958
        $this->pdf->line($x, $y, $w + 1, $y);
2959
        $texto = 'DCL';
2960
        $aFont = array(
2961
            'font' => $this->fontePadrao,
2962
            'size' => 7,
2963
            'style' => 'B');
2964
        $this->pdf->textBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2965
        $this->pdf->line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2966
        $texto = 'VAGÕES';
2967
        $aFont = array(
2968
            'font' => $this->fontePadrao,
2969
            'size' => 7,
2970
            'style' => 'B');
2971
        $this->pdf->textBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2972
        $y += 3.4;
2973
        $this->pdf->line($x, $y, $w + 1, $y);
2974
        // DCL
2975
        $texto = 'ID TREM';
2976
        $aFont = array(
2977
            'font' => $this->fontePadrao,
2978
            'size' => 6,
2979
            'style' => '');
2980
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2981
        $texto = $this->getTagValue($this->ferrov, "idTrem");
2982
        $aFont = array(
2983
            'font' => $this->fontePadrao,
2984
            'size' => 6,
2985
            'style' => 'B');
2986
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2987
        $x += $w * 0.06;
2988
        $y1 = $y + 12.5;
2989
        $this->pdf->line($x, $y, $x, $y1);
2990
        $texto = 'NUM';
2991
        $aFont = array(
2992
            'font' => $this->fontePadrao,
2993
            'size' => 6,
2994
            'style' => '');
2995
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2996
        $texto = $this->getTagValue($this->rem, "nDoc");
2997
        $aFont = array(
2998
            'font' => $this->fontePadrao,
2999
            'size' => 6,
3000
            'style' => 'B');
3001
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3002
        $x += $w * 0.06;
3003
        $this->pdf->line($x, $y, $x, $y1);
3004
        $texto = 'SÉRIE';
3005
        $aFont = array(
3006
            'font' => $this->fontePadrao,
3007
            'size' => 6,
3008
            'style' => '');
3009
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3010
        $texto = $this->getTagValue($this->rem, "serie");
3011
        $aFont = array(
3012
            'font' => $this->fontePadrao,
3013
            'size' => 6,
3014
            'style' => 'B');
3015
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3016
        $x += $w * 0.06;
3017
        $this->pdf->line($x, $y, $x, $y1);
3018
        $texto = 'EMISSÃO';
3019
        $aFont = array(
3020
            'font' => $this->fontePadrao,
3021
            'size' => 6,
3022
            'style' => '');
3023
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3024
        $texto = $this->pYmd2dmy($this->getTagValue($this->rem, "dEmi"));
0 ignored issues
show
Bug introduced by
The method pYmd2dmy() does not seem to exist on object<NFePHP\DA\CTe\Dacte>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
3025
        $aFont = array(
3026
            'font' => $this->fontePadrao,
3027
            'size' => 6,
3028
            'style' => 'B');
3029
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3030
        // VAGOES
3031
        $x += $w * 0.06;
3032
        $this->pdf->line($x, $y, $x, $y1);
3033
        $texto = 'NUM';
3034
        $aFont = array(
3035
            'font' => $this->fontePadrao,
3036
            'size' => 6,
3037
            'style' => '');
3038
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3039
        $texto = $this->getTagValue($this->ferrov, "nVag");
3040
        $aFont = array(
3041
            'font' => $this->fontePadrao,
3042
            'size' => 6,
3043
            'style' => 'B');
3044
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3045
        $x += $w * 0.06;
3046
        $this->pdf->line($x, $y, $x, $y1);
3047
        $texto = 'TIPO';
3048
        $aFont = array(
3049
            'font' => $this->fontePadrao,
3050
            'size' => 6,
3051
            'style' => '');
3052
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3053
        $texto = $this->getTagValue($this->ferrov, "tpVag");
3054
        $aFont = array(
3055
            'font' => $this->fontePadrao,
3056
            'size' => 6,
3057
            'style' => 'B');
3058
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3059
        $x += $w * 0.06;
3060
        $this->pdf->line($x, $y, $x, $y1);
3061
        $texto = 'CAPACIDADE';
3062
        $aFont = array(
3063
            'font' => $this->fontePadrao,
3064
            'size' => 6,
3065
            'style' => '');
3066
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3067
        $texto = $this->getTagValue($this->ferrov, "cap");
3068
        $aFont = array(
3069
            'font' => $this->fontePadrao,
3070
            'size' => 6,
3071
            'style' => 'B');
3072
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3073
        $x += $w * 0.08;
3074
        $this->pdf->line($x, $y, $x, $y1);
3075
        $texto = 'PESO REAL/TON';
3076
        $aFont = array(
3077
            'font' => $this->fontePadrao,
3078
            'size' => 6,
3079
            'style' => '');
3080
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3081
        $texto = $this->getTagValue($this->ferrov, "pesoR");
3082
        $aFont = array(
3083
            'font' => $this->fontePadrao,
3084
            'size' => 6,
3085
            'style' => 'B');
3086
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3087
        $x += $w * 0.09;
3088
        $this->pdf->line($x, $y, $x, $y1);
3089
        $texto = 'PESO BRUTO/TON';
3090
        $aFont = array(
3091
            'font' => $this->fontePadrao,
3092
            'size' => 6,
3093
            'style' => '');
3094
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3095
        $texto = $this->getTagValue($this->ferrov, "pesoBC");
3096
        $aFont = array(
3097
            'font' => $this->fontePadrao,
3098
            'size' => 6,
3099
            'style' => 'B');
3100
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3101
        $x += $w * 0.1;
3102
        $this->pdf->line($x, $y, $x, $y1);
3103
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3104
        $aFont = array(
3105
            'font' => $this->fontePadrao,
3106
            'size' => 6,
3107
            'style' => '');
3108
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3109
        $texto = $this->getTagValue($this->ferrov, "nCont");
3110
        $aFont = array(
3111
            'font' => $this->fontePadrao,
3112
            'size' => 6,
3113
            'style' => 'B');
3114
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3115
        // FLUXO
3116
        $x = 1;
3117
        $y += 12.9;
3118
        $h1 = $h * 0.5 + 0.27;
3119
        $wa = round($w * 0.103) + 0.5;
3120
        $texto = 'FLUXO FERROVIARIO';
3121
        $aFont = $this->formatPadrao;
3122
        $this->pdf->textBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3123
        $texto = $this->getTagValue($this->ferrov, "fluxo");
3124
        $aFont = array(
3125
            'font' => $this->fontePadrao,
3126
            'size' => 7,
3127
            'style' => 'B');
3128
        $this->pdf->textBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3129
        $y += 10;
3130
        $texto = 'TIPO DE TRÁFEGO';
3131
        $aFont = $this->formatPadrao;
3132
        $this->pdf->textBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3133
        $texto = $this->convertUnidTrafego($this->getTagValue($this->ferrov, "tpTraf"));
3134
        $aFont = array(
3135
            'font' => $this->fontePadrao,
3136
            'size' => 7,
3137
            'style' => 'B');
3138
        $this->pdf->textBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3139
        // Novo Box Relativo a Modal Ferroviário
3140
        $x = 22.5;
3141
        $y += -10.2;
3142
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3143
        $aFont = $this->formatPadrao;
3144
        $this->pdf->textBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3145
        $y += 3.4;
3146
        $this->pdf->line($x, $y, $w + 1, $y);
3147
        $w = $w * 0.2;
3148
        $h = $h * 1.04;
3149
        $texto = 'CÓDIGO INTERNO';
3150
        $aFont = array(
3151
            'font' => $this->fontePadrao,
3152
            'size' => 6,
3153
            'style' => '');
3154
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3155
        $texto = $this->getTagValue($this->ferrov, "cInt");
3156
        $aFont = array(
3157
            'font' => $this->fontePadrao,
3158
            'size' => 6,
3159
            'style' => 'B');
3160
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3161
        $texto = 'CNPJ';
3162
        $aFont = array(
3163
            'font' => $this->fontePadrao,
3164
            'size' => 6,
3165
            'style' => '');
3166
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3167
        $texto = $this->getTagValue($this->ferrov, "CNPJ");
3168
        $aFont = array(
3169
            'font' => $this->fontePadrao,
3170
            'size' => 6,
3171
            'style' => 'B');
3172
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3173
        $x += 50;
3174
        $texto = 'NOME';
3175
        $aFont = array(
3176
            'font' => $this->fontePadrao,
3177
            'size' => 6,
3178
            'style' => '');
3179
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3180
        $texto = $this->getTagValue($this->ferrov, "xNome");
3181
        $aFont = array(
3182
            'font' => $this->fontePadrao,
3183
            'size' => 6,
3184
            'style' => 'B');
3185
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3186
        $texto = 'INSCRICAO ESTADUAL';
3187
        $aFont = array(
3188
            'font' => $this->fontePadrao,
3189
            'size' => 6,
3190
            'style' => '');
3191
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3192
        $texto = $this->getTagValue($this->ferrov, "IE");
3193
        $aFont = array(
3194
            'font' => $this->fontePadrao,
3195
            'size' => 6,
3196
            'style' => 'B');
3197
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3198
        $x += 50;
3199
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3200
        $aFont = array(
3201
            'font' => $this->fontePadrao,
3202
            'size' => 6,
3203
            'style' => '');
3204
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3205
        $texto = '';
3206
        $aFont = array(
3207
            'font' => $this->fontePadrao,
3208
            'size' => 6,
3209
            'style' => 'B');
3210
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3211
    }
3212
3213
    /**
3214
     * canhoto
3215
     * Monta o campo com os dados do remetente na DACTE.
3216
     *
3217
     * @param  number $x Posição horizontal canto esquerdo
3218
     * @param  number $y Posição vertical canto superior
3219
     * @return number Posição vertical final
3220
     */
3221
    protected function canhoto($x = 0, $y = 0)
3222
    {
3223
        $oldX = $x;
3224
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
3225
        if ($this->orientacao == 'P') {
3226
            $maxW = $this->wPrint;
3227
        } else {
3228
            $maxW = $this->wPrint - $this->wCanhoto;
3229
        }
3230
        $w = $maxW - 1;
3231
        $h = 20;
3232
        $y = $y + 1;
3233
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3234
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3235
        $aFont = $this->formatPadrao;
3236
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3237
        $y += 3.4;
3238
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3239
        $texto = 'NOME';
3240
        $aFont = array(
3241
            'font' => $this->fontePadrao,
3242
            'size' => 6,
3243
            'style' => '');
3244
        $this->pdf->textBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3245
        $x += $w * 0.25;
3246
        $this->pdf->line($x, $y, $x, $y + 16.5);
3247
        $texto = 'ASSINATURA / CARIMBO';
3248
        $aFont = array(
3249
            'font' => $this->fontePadrao,
3250
            'size' => 6,
3251
            'style' => '');
3252
        $this->pdf->textBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3253
        $x += $w * 0.25;
3254
        $this->pdf->line($x, $y, $x, $y + 16.5);
3255
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
3256
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3257
        $aFont = array(
3258
            'font' => $this->fontePadrao,
3259
            'size' => 6,
3260
            'style' => '');
3261
        $this->pdf->textBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3262
        $x = $oldX;
3263
        $y = $y + 5;
3264
        $this->pdf->line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3265
        $texto = 'RG';
3266
        $aFont = array(
3267
            'font' => $this->fontePadrao,
3268
            'size' => 6,
3269
            'style' => '');
3270
        $this->pdf->textBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3271
        $x += $w * 0.85;
3272
        $this->pdf->line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3273
        $texto = "CT-E";
3274
        $aFont = $this->formatNegrito;
3275
        $this->pdf->textBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3276
        $texto = "\r\n Nº. DOCUMENTO  " . $this->getTagValue($this->ide, "nCT") . " \n";
3277
        $texto .= "\r\n SÉRIE  " . $this->getTagValue($this->ide, "serie");
3278
        $aFont = array(
3279
            'font' => $this->fontePadrao,
3280
            'size' => 6,
3281
            'style' => '');
3282
        $this->pdf->textBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3283
        $x = $oldX;
3284
        $this->pdf->dashedHLine($x, $y + 12.7, $this->wPrint, 0.1, 80);
3285
    }
3286
3287
    /**
3288
     * dadosAdic
3289
     * Coloca o grupo de dados adicionais da DACTE.
3290
     *
3291
     * @param  number $x Posição horizontal canto esquerdo
3292
     * @param  number $y Posição vertical canto superior
3293
     * @param  number $h altura do campo
3294
     * @return number Posição vertical final
3295
     */
3296
    protected function dadosAdic($x, $y, $pag, $h)
0 ignored issues
show
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 $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...
3297
    {
3298
        $oldX = $x;
0 ignored issues
show
Unused Code introduced by
$oldX 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...
3299
        //###########################################################################
3300
        //DADOS ADICIONAIS DACTE
3301
        if ($this->orientacao == 'P') {
3302
            $w = $this->wPrint;
0 ignored issues
show
Unused Code introduced by
$w 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...
3303
        } else {
3304
            $w = $this->wPrint - $this->wCanhoto;
0 ignored issues
show
Unused Code introduced by
$w 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...
3305
        }
3306
        //INFORMAÇÕES COMPLEMENTARES
3307
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3308
        $y += 3;
3309
        $w = $this->wAdic;
3310
        $h = 8; //mudar
3311
        $aFont = array(
3312
            'font' => $this->fontePadrao,
3313
            'size' => 6,
3314
            'style' => '');
3315
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3316
        //$this->pdf->line($x, $y + 3, $w * 1.385, $y + 3);
3317
        $this->pdf->line($x, $y + 3, $w * 1.385, $y + 3);
3318
        //o texto com os dados adicionais foi obtido na função xxxxxx
3319
        //e carregado em uma propriedade privada da classe
3320
        //$this->wAdic com a largura do campo
3321
        //$this->textoAdic com o texto completo do campo
3322
        $y += 1;
3323
        $aFont = $this->formatPadrao;
3324
        $this->pdf->textBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3325
        //RESERVADO AO FISCO
3326
        $texto = "RESERVADO AO FISCO";
3327
        $x += $w;
3328
        $y -= 1;
3329
        if ($this->orientacao == 'P') {
3330
            $w = $this->wPrint - $w;
3331
        } else {
3332
            $w = $this->wPrint - $w - $this->wCanhoto;
3333
        }
3334
        $aFont = array(
3335
            'font' => $this->fontePadrao,
3336
            'size' => 6,
3337
            'style' => '');
3338
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3339
        //inserir texto informando caso de contingência
3340
        //1 – Normal – emissão normal;
3341
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3342
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3343
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3344
        //Emissão em Contingência – DPEC;
3345
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3346
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3347
        $xJust = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
3348
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3349
        $texto = '';
3350
        switch ($this->tpEmis) {
3351
            case 2:
3352
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3353
                break;
3354
            case 3:
3355
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3356
                break;
3357
            case 4:
3358
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3359
                break;
3360
            case 5:
3361
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3362
                break;
3363
        }
3364
        $y += 2;
3365
        $aFont = $this->formatPadrao;
3366
        $this->pdf->textBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3367
        return $y + $h;
3368
    }
3369
3370
    /**
3371
     * formatCNPJCPF
3372
     * Formata campo CnpjCpf contida na CTe
3373
     *
3374
     * @param  string $field campo cnpjCpf da CT-e
3375
     * @return string
3376
     */
3377
    protected function formatCNPJCPF($field)
3378
    {
3379
        if (!isset($field)) {
3380
            return '';
3381
        }
3382
        $cnpj = !empty($field->getElementsByTagName("CNPJ")->item(0)->nodeValue) ?
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3383
            $field->getElementsByTagName("CNPJ")->item(0)->nodeValue : "";
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3384
        if ($cnpj != "" && $cnpj != "00000000000000") {
3385
            $cnpj = $this->formatField($cnpj, '###.###.###/####-##');
3386
        } else {
3387
            $cnpj = !empty($field->getElementsByTagName("CPF")->item(0)->nodeValue) ?
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3388
                $this->formatField($field->getElementsByTagName("CPF")->item(0)->nodeValue, '###.###.###.###-##') : '';
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3389
        }
3390
        return $cnpj;
3391
    }
3392
3393
    /**
3394
     * formatFone
3395
     * Formata campo fone contida na CTe
3396
     *
3397
     * @param  string $field campo fone da CT-e
3398
     * @return string
3399
     */
3400
    protected function formatFone($field)
3401
    {
3402
        try {
3403
            $fone = !empty($field->getElementsByTagName("fone")->item(0)->nodeValue) ?
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3404
            $field->getElementsByTagName("fone")->item(0)->nodeValue : '';
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3405
            $foneLen = strlen($fone);
3406
            if ($foneLen > 0) {
3407
                $fone2 = substr($fone, 0, $foneLen - 4);
3408
                $fone1 = substr($fone, 0, $foneLen - 8);
3409
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3410
            } else {
3411
                $fone = '';
3412
            }
3413
            return $fone;
3414
        } catch (Exception $exc) {
3415
            return '';
3416
        }
3417
    }
3418
3419
    /**
3420
     * unidade
3421
     * Converte a imformação de peso contida na CTe
3422
     *
3423
     * @param  string $c unidade de trafego extraida da CTe
3424
     * @return string
3425
     */
3426
    protected function unidade($c = '')
3427
    {
3428
        switch ($c) {
3429
            case '00':
3430
                $r = 'M3';
3431
                break;
3432
            case '01':
3433
                $r = 'KG';
3434
                break;
3435
            case '02':
3436
                $r = 'TON';
3437
                break;
3438
            case '03':
3439
                $r = 'UN';
3440
                break;
3441
            case '04':
3442
                $r = 'LT';
3443
                break;
3444
            case '05':
3445
                $r = 'MMBTU';
3446
                break;
3447
            default:
3448
                $r = '';
3449
        }
3450
        return $r;
3451
    }
3452
3453
    /**
3454
     * convertUnidTrafego
3455
     * Converte a imformação de peso contida na CTe
3456
     *
3457
     * @param  string $U Informação de trafego extraida da CTe
3458
     * @return string
3459
     */
3460
    protected function convertUnidTrafego($U = '')
3461
    {
3462
        if ($U) {
3463
            switch ($U) {
3464
                case '0':
3465
                    $stringU = 'Próprio';
3466
                    break;
3467
                case '1':
3468
                    $stringU = 'Mútuo';
3469
                    break;
3470
                case '2':
3471
                    $stringU = 'Rodoferroviário';
3472
                    break;
3473
                case '3':
3474
                    $stringU = 'Rodoviário';
3475
                    break;
3476
            }
3477
            return $stringU;
0 ignored issues
show
Bug introduced by
The variable $stringU 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...
3478
        }
3479
    }
3480
3481
    /**
3482
     * multiUniPeso
3483
     * Fornece a imformação multiplicação de peso contida na CTe
3484
     *
3485
     * @param  interger $U Informação de peso extraida da CTe
3486
     * @return interger
3487
     */
3488
    protected function multiUniPeso($U = '')
3489
    {
3490
        if ($U === "01") {
3491
            // tonelada
3492
            //return 1000;
3493
            return 1;
3494
        }
3495
        return 1; // M3, KG, Unidade, litros, mmbtu
3496
    }
3497
3498
    protected function qrCodeDacte($y = 0)
3499
    {
3500
        $margemInterna = $this->margemInterna;
3501
        $barcode = new Barcode();
3502
        $bobj = $barcode->getBarcodeObj(
3503
            'QRCODE,M',
3504
            $this->qrCodCTe,
3505
            -4,
3506
            -4,
3507
            'black',
3508
            array(-2, -2, -2, -2)
3509
        )->setBackgroundColor('white');
3510
        $qrcode = $bobj->getPngData();
3511
        $wQr = 36;
3512
        $hQr = 36;
3513
        $yQr = ($y + $margemInterna);
3514
        if ($this->orientacao == 'P') {
3515
            $xQr = 170;
3516
        } else {
3517
            $xQr = 250;
3518
        }
3519
        // prepare a base64 encoded "data url"
3520
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
3521
        $this->pdf->image($pic, $xQr - 3, $yQr, $wQr, $hQr, 'PNG');
3522
    }
3523
}
3524