Completed
Push — master ( a9c9d6...4270ed )
by Roberto
10:53 queued 05:58
created

Dacte::zDocOrigContinuacao()   C

Complexity

Conditions 8
Paths 48

Size

Total Lines 108
Code Lines 87

Duplication

Lines 16
Ratio 14.81 %

Code Coverage

Tests 0
CRAP Score 72

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 8
eloc 87
c 1
b 0
f 0
nc 48
nop 2
dl 16
loc 108
ccs 0
cts 95
cp 0
crap 72
rs 5.2676

How to fix   Long Method   

Long Method

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

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

Commonly applied refactorings include:

1
<?php
2
3
namespace NFePHP\DA\CTe;
4
5
/**
6
 * Classe para ageração do PDF da CTe, conforme regras e estruturas
7
 * estabelecidas pela SEFAZ.
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Dacte .php
12
 * @copyright 2009-2016 NFePHP
13
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Roberto L. Machado <linux dot rlm at gmail dot com>
16
 */
17
18
use Exception;
19
use NFePHP\Common\Dom\Dom;
20
use NFePHP\DA\Legacy\Pdf;
21
use NFePHP\DA\Legacy\Common;
22
23
class Dacte extends Common
24
{
25
    const NFEPHP_SITUACAO_EXTERNA_CANCELADA = 1;
26
    const NFEPHP_SITUACAO_EXTERNA_DENEGADA = 2;
27
    const SIT_DPEC = 3;
28
29
    protected $logoAlign = 'C';
30
    protected $yDados = 0;
31
    protected $situacao_externa = 0;
32
    protected $numero_registro_dpec = '';
33
    protected $pdf;
34
    protected $xml;
35
    protected $logomarca = '';
36
    protected $errMsg = '';
37
    protected $errStatus = false;
38
    protected $orientacao = 'P';
39
    protected $papel = 'A4';
40
    protected $destino = 'I';
41
    protected $pdfDir = '';
42
    protected $fontePadrao = 'Times';
43
    protected $version = '1.3.0';
44
    protected $wPrint;
45
    protected $hPrint;
46
    protected $dom;
47
    protected $infCte;
48
    protected $infCteComp;
49
    protected $chaveCTeRef;
50
    protected $tpCTe;
51
    protected $ide;
52
    protected $emit;
53
    protected $enderEmit;
54
    protected $rem;
55
    protected $enderReme;
56
    protected $dest;
57
    protected $enderDest;
58
    protected $exped;
59
    protected $enderExped;
60
    protected $receb;
61
    protected $enderReceb;
62
    protected $infCarga;
63
    protected $infQ;
64
    protected $seg;
65
    protected $modal;
66
    protected $rodo;
67
    protected $moto;
68
    protected $veic;
69
    protected $ferrov;
70
    protected $Comp;
71
    protected $infNF;
72
    protected $infNFe;
73
    protected $compl;
74
    protected $ICMS;
75
    protected $imp;
76
    protected $toma4;
77
    protected $toma03;
78
    protected $tpEmis;
79
    protected $tpImp;
80
    protected $tpAmb;
81
    protected $vPrest;
82
    protected $wAdic = 150;
83
    protected $textoAdic = '';
84
    protected $debugMode = 2;
85
    protected $formatPadrao;
86
    protected $formatNegrito;
87
    protected $aquav;
88
    protected $preVisualizar;
89
    protected $flagDocOrigContinuacao;
90
    protected $arrayNFe = array();
91
92
    /**
93
     * __construct
94
     *
95
     * @param string $docXML Arquivo XML da CTe
96
     * @param string $sOrientacao (Opcional) Orientação da impressão P ou L
97
     * @param string $sPapel Tamanho do papel (Ex. A4)
98
     * @param string $sPathLogo Caminho para o arquivo do logo
99
     * @param string $sDestino Estabelece a direção do envio do documento PDF
100
     * @param string $sDirPDF Caminho para o diretorio de armaz. dos PDF
101
     * @param string $fonteDACTE Nome da fonte a ser utilizada
102
     * @param number $mododebug 0-Não 1-Sim e 2-nada (2 default)
103
     * @param string $preVisualizar 0-Não 1-Sim
104
     */
105
    public function __construct(
106
        $docXML = '',
107
        $sOrientacao = '',
108
        $sPapel = '',
109
        $sPathLogo = '',
110
        $sDestino = 'I',
111
        $sDirPDF = '',
112
        $fonteDACTE = '',
113
        $mododebug = 2,
114
        $preVisualizar = false
115
    ) {
116
    
117
        if (is_numeric($mododebug)) {
118
            $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...
119
        }
120
        if ($mododebug == 1) {
121
            //ativar modo debug
122
            error_reporting(E_ALL);
123
            ini_set('display_errors', 'On');
124
        } elseif ($mododebug == 0) {
125
            //desativar modo debug
126
            error_reporting(0);
127
            ini_set('display_errors', 'Off');
128
        }
129
        $this->orientacao = $sOrientacao;
130
        $this->papel = $sPapel;
131
        $this->pdf = '';
132
        $this->xml = $docXML;
133
        $this->logomarca = $sPathLogo;
134
        $this->destino = $sDestino;
135
        $this->pdfDir = $sDirPDF;
136
        $this->preVisualizar = $preVisualizar;
137
        // verifica se foi passa a fonte a ser usada
138
        if (!empty($fonteDACTE)) {
139
            $this->fontePadrao = $fonteDACTE;
140
        }
141
        $this->formatPadrao = array(
142
            'font' => $this->fontePadrao,
143
            'size' => 6,
144
            'style' => '');
145
        $this->formatNegrito = array(
146
            'font' => $this->fontePadrao,
147
            'size' => 7,
148
            'style' => 'B');
149
        //se for passado o xml
150
        if (!empty($this->xml)) {
151
            $this->dom = new Dom();
152
            $this->dom->loadXML($this->xml);
153
            $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...
154
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
155
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
156
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
157
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
158
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
159
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
160
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
161
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
162
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
163
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
164
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
165
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
166
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
167
            $this->infQ = $this->dom->getElementsByTagName("infQ");
168
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
169
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
170
            $this->lota = $this->pSimpleGetValue($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...
171
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
172
            $this->veic = $this->dom->getElementsByTagName("veic");
173
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
174
            // adicionar outros modais
175
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
176
            $this->chaveCTeRef = $this->pSimpleGetValue($this->infCteComp, "chave");
177
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
178
            $this->Comp = $this->dom->getElementsByTagName("Comp");
179
            $this->infNF = $this->dom->getElementsByTagName("infNF");
180
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
181
            $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...
182
            $this->compl = $this->dom->getElementsByTagName("compl");
183
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
184
            $this->ICMSSN = $this->dom->getElementsByTagName("ICMSSN")->item(0);
0 ignored issues
show
Bug introduced by
The property ICMSSN 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->imp = $this->dom->getElementsByTagName("imp")->item(0);
186
            $textoAdic = number_format($this->pSimpleGetValue($this->imp, "vTotTrib"), 2, ",", ".");
187
            $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
188
                    .$textoAdic;
189
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
190
            $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
191
            //modal aquaviário
192
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
193
            $tomador = $this->pSimpleGetValue($this->toma03, "toma");
194
            //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4-Outros
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
195
            switch ($tomador) {
196
                case '0':
197
                    $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...
198
                    $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...
199
                    break;
200
                case '1':
201
                    $this->toma = $this->exped;
202
                    $this->enderToma = $this->enderExped;
203
                    break;
204
                case '2':
205
                    $this->toma = $this->receb;
206
                    $this->enderToma = $this->enderReceb;
207
                    break;
208
                case '3':
209
                    $this->toma = $this->dest;
210
                    $this->enderToma = $this->enderDest;
211
                    break;
212
                default:
213
                    $this->toma = $this->toma4;
214
                    $this->enderToma = $this->pSimpleGetValue($this->toma4, "enderToma");
215
                    break;
216
            }
217
            $seguro = $this->pSimpleGetValue($this->seg, "respSeg");
218
            switch ($seguro) {
219
                case '0':
220
                    $this->respSeg = 'Remetente';
0 ignored issues
show
Bug introduced by
The property respSeg 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...
221
                    break;
222
                case '1':
223
                    $this->respSeg = 'Expedidor';
224
                    break;
225
                case '2':
226
                    $this->respSeg = 'Recebedor';
227
                    break;
228
                case '3':
229
                    $this->respSeg = 'Destinatário';
230
                    break;
231
                case '4':
232
                    $this->respSeg = 'Emitente';
233
                    break;
234
                case '5':
235
                    $this->respSeg = 'Tomador';
236
                    break;
237
                default:
238
                    $this->respSeg = '';
239
                    break;
240
            }
241
            $this->tpEmis = $this->pSimpleGetValue($this->ide, "tpEmis");
242
            $this->tpImp = $this->pSimpleGetValue($this->ide, "tpImp");
243
            $this->tpAmb = $this->pSimpleGetValue($this->ide, "tpAmb");
244
            $this->tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
245
            $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...
246
        }
247
    }
248
249
    /**
250
     * monta
251
     * @param string $orientacao L ou P
252
     * @param string $papel A4
253
     * @param string $logoAlign C, L ou R
254
     * @param Pdf $classPDF
255
     * @return string montagem
256
     */
257
    public function monta(
258
        $orientacao = '',
259
        $papel = 'A4',
260
        $logoAlign = 'C',
261
        $classPDF = false
262
    ) {
263
    
264
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 261 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...
265
    }
266
267
    /**
268
     * printDocument
269
     * @param string $nome
270
     * @param string $destino
271
     * @param string $printer
272
     * @return
273
     */
274
    public function printDocument($nome = '', $destino = 'I', $printer = '')
275
    {
276
        return $this->printDACTE($nome, $destino, $printer);
277
    }
278
279
    /**
280
     * Dados brutos do PDF
281
     * @return string
282
     */
283
    public function render()
284
    {
285
        return $this->pdf->getPdf();
286
    }
287
288
289
    protected function zCteDPEC()
290
    {
291
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
292
    }
293
294
295
    /**
296
     * montaDACTE
297
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
298
     * durante sua construção.
299
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
300
     * pelo conteúdo da funçao e podem ser modificados.
301
     *
302
     * @param  string $orientacao (Opcional) Estabelece a orientação da
303
     *                impressão (ex. P-retrato), se nada for fornecido será
304
     *                usado o padrão da NFe
305
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
306
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
307
     */
308
    public function montaDACTE(
309
        $orientacao = '',
310
        $papel = 'A4',
311
        $logoAlign = 'C',
312
        $classPDF = false
313
    ) {
314
    
315
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
316 View Code Duplication
        if ($orientacao == '') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
317
            if ($this->tpImp == '1') {
318
                $orientacao = 'P';
319
            } else {
320
                $orientacao = 'P';
321
            }
322
        }
323
        $this->orientacao = $orientacao;
324
        $this->papel = $papel;
325
        $this->logoAlign = $logoAlign;
326
327
        //$this->situacao_externa = $situacao_externa;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
328
        //instancia a classe pdf
329
        if ($classPDF !== false) {
330
            $this->pdf = $classPDF;
331
        } else {
332
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
333
        }
334
        if ($this->orientacao == 'P') {
335
            // margens do PDF
336
            $margSup = 2;
337
            $margEsq = 2;
338
            $margDir = 2;
339
            // posição inicial do relatorio
340
            $xInic = 1;
341
            $yInic = 1;
342
            if ($papel == 'A4') {
343
                //A4 210x297mm
344
                $maxW = 210;
345
                $maxH = 297;
346
            }
347
        } else {
348
            // margens do PDF
349
            $margSup = 3;
350
            $margEsq = 3;
351
            $margDir = 3;
352
            // posição inicial do relatorio
353
            $xInic = 5;
354
            $yInic = 5;
355
            if ($papel == 'A4') {
356
                //A4 210x297mm
357
                $maxH = 210;
358
                $maxW = 297;
359
                $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...
360
            }
361
        }
362
        //total inicial de paginas
363
        $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...
364
        //largura imprimivel em mm
365
        $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...
366
        //comprimento imprimivel em mm
367
        $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...
368
        // estabelece contagem de paginas
369
        $this->pdf->AliasNbPages();
370
        // fixa as margens
371
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
372
        $this->pdf->SetDrawColor(0, 0, 0);
373
        $this->pdf->SetFillColor(255, 255, 255);
374
        // inicia o documento
375
        $this->pdf->Open();
376
        // adiciona a primeira página
377
        $this->pdf->AddPage($this->orientacao, $this->papel);
378
        $this->pdf->SetLineWidth(0.1);
379
        $this->pdf->SetTextColor(0, 0, 0);
380
        //calculo do numero de páginas ???
381
        $totPag = 1;
382
        //montagem da primeira página
383
        $pag = 1;
384
        $x = $xInic;
385
        $y = $yInic;
386
        //coloca o cabeçalho
387
        //$r = $this->zCabecalho($x, $y, $pag, $totPag);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
388
        $y += 70;
389
        $r = $this->zRemetente($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...
390
        $x = $this->wPrint * 0.5 + 2;
391
        $r = $this->zDestinatario($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...
392
        $y += 19;
393
        $x = $xInic;
394
        $r = $this->zExpedidor($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
        $x = $this->wPrint * 0.5 + 2;
396
        $r = $this->zRecebedor($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...
397
        $y += 19;
398
        $x = $xInic;
399
        $r = $this->zTomador($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
        if ($this->tpCTe == '0') {
401
            //Normal
402
            $y += 10;
403
            $x = $xInic;
404
            $r = $this->zDescricaoCarga($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...
405
            $y += 17;
406
            $x = $xInic;
407
            $r = $this->zCompValorServ($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 += 25;
409
            $x = $xInic;
410
            $r = $this->zImpostos($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 += 13;
412
            $x = $xInic;
413
            $r = $this->zDocOrig($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 View Code Duplication
            if ($this->modal == '1') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
415
                if ($this->lota == 1) {
416
                    //$y += 24.95;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
417
                    $y += 35;
418
                } else {
419
                    $y += 53;
420
                }
421
            } elseif ($this->modal == '3') {
422
                $y += 37.75;
423
            } else {
424
                $y += 24.95;
425
            }
426
            $x = $xInic;
427
            $r = $this->zObs($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...
428
            $y = $y-6;
429
            switch ($this->modal) {
430
                case '1':
431
                    $y += 17.9;
432
                    $x = $xInic;
433
                    $r = $this->zModalRod($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...
434
                    break;
435
                case '2':
436
                    $y += 17.9;
437
                    $x = $xInic;
438
                    // TODO fmertins 31/10/14: este método não existe...
439
                    $r = $this->zModalAereo($x, $y);
0 ignored issues
show
Bug introduced by
The method zModalAereo() 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...
440
                    break;
441
                case '3':
442
                    $y += 17.9;
443
                    $x = $xInic;
444
                    $r = $this->zModalAquaviario($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...
445
                    break;
446
                case '4':
447
                    $y += 17.9;
448
                    $x = $xInic;
449
                    $r = $this->zModalFerr($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...
450
                    break;
451
                case '5':
452
                    $y += 17.9;
453
                    $x = $xInic;
454
                    // TODO fmertins 31/10/14: este método não existe...
455
                    $r = $this->zModalDutoviario($x, $y);
0 ignored issues
show
Bug introduced by
The method zModalDutoviario() 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...
456
                    break;
457
            }
458 View Code Duplication
            if ($this->modal == '1') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
459
                if ($this->lota == 1) {
460
                    $y += 37;
461
                } else {
462
                    $y += 8.9;
463
                }
464
            } elseif ($this->modal == '3') {
465
                $y += 24.15;
466
            } else {
467
                $y += 37;
468
            }
469
        } else {
470
            //Complementado
471
            $y += 10;
472
            $x = $xInic;
473
            $r = $this->zDocCompl($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...
474
            $y += 80;
475
            $x = $xInic;
476
            $r = $this->zCompValorServ($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...
477
            $y += 25;
478
            $x = $xInic;
479
            $r = $this->zImpostos($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...
480
            $y += 13;
481
            $x = $xInic;
482
            $r = $this->zObs($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...
483
            $y += 15;
484
        }
485
        $x = $xInic;
486
        $r = $this->zDadosAdic($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...
487
        
488
        //$y += 19;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
489
        $y += 10;
490
        $y = $this->zCanhoto($x, $y);
0 ignored issues
show
Unused Code introduced by
$y is not used, you could remove the assignment.

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

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

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

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

Loading history...
491
        
492
        //coloca o rodapé da página
493
        if ($this->orientacao == 'P') {
494
            $this->zRodape(2, $this->hPrint - 2);
495
        } else {
496
            $this->zRodape($xInic, $this->hPrint + 2.3);
497
        }
498
        if ($this->flagDocOrigContinuacao == 1) {
499
            $this->zdocOrigContinuacao(1, 71);
500
        }
501
        //retorna o ID na CTe
502 View Code Duplication
        if ($classPDF !== false) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
503
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
504
            return $aR;
505
        } else {
506
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
507
        }
508
    } //fim da função montaDACTE
509
510
    /**
511
     * printDACTE
512
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
513
     * O destino da impressão pode ser :
514
     * I-browser
515
     * D-browser com download
516
     * F-salva em um arquivo local com o nome informado
517
     * S-retorna o documento como uma string e o nome é ignorado.
518
     * Para enviar o pdf diretamente para uma impressora indique o
519
     * nome da impressora e o destino deve ser 'S'.
520
     *
521
     * @param  string $nome Path completo com o nome do arquivo pdf
522
     * @param  string $destino Direção do envio do PDF
523
     * @param  string $printer Identificação da impressora no sistema
524
     * @return string Caso o destino seja S o pdf é retornado como uma string
525
     * @todo Rotina de impressão direta do arquivo pdf criado
526
     */
527 View Code Duplication
    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...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
528
    {
529
        $arq = $this->pdf->Output($nome, $destino);
530
        if ($destino == 'S') {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
531
            //aqui pode entrar a rotina de impressão direta
532
        }
533
        return $arq;
534
    } //fim função printDACTE
535
536
    /**
537
     * zCabecalho
538
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
539
     *
540
     * @param  number $x Posição horizontal inicial, canto esquerdo
541
     * @param  number $y Posição vertical inicial, canto superior
542
     * @param  number $pag Número da Página
543
     * @param  number $totPag Total de páginas
544
     * @return number Posição vertical final
545
     */
546
    protected function zCabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
547
    {
548
        $oldX = $x;
549
        $oldY = $y;
550
        if ($this->orientacao == 'P') {
551
            $maxW = $this->wPrint;
552
        } else {
553
            if ($pag == 1) {
554
                // primeira página
555
                $maxW = $this->wPrint - $this->wCanhoto;
556
            } else {
557
                // páginas seguintes
558
                $maxW = $this->wPrint;
559
            }
560
        }
561
        //##################################################################
562
        //coluna esquerda identificação do emitente
563
        $w = round($maxW * 0.42);
564
        if ($this->orientacao == 'P') {
565
            $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...
566
                'font' => $this->fontePadrao,
567
                'size' => 6,
568
                'style' => '');
569
        } else {
570
            $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...
571
        }
572
        $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...
573
        $h = 35;
574
        $oldY += $h;
575
        //desenha a caixa
576
        $this->pTextBox($x, $y, $w + 2, $h + 1);
577
        // coloca o logo
578 View Code Duplication
        if (is_file($this->logomarca)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
579
            $logoInfo = getimagesize($this->logomarca);
580
            //largura da imagem em mm
581
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
582
            //altura da imagem em mm
583
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
584
            if ($this->logoAlign == 'L') {
585
                $nImgW = round($w / 3, 0);
586
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
587
                $xImg = $x + 1;
588
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
589
                //estabelecer posições do texto
590
                $x1 = round($xImg + $nImgW + 1, 0);
591
                $y1 = round($h / 3 + $y, 0);
592
                $tw = round(2 * $w / 3, 0);
593
            } elseif ($this->logoAlign == 'C') {
594
                $nImgH = round($h / 3, 0);
595
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
596
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
597
                $yImg = $y + 3;
598
                $x1 = $x;
599
                $y1 = round($yImg + $nImgH + 1, 0);
600
                $tw = $w;
601
            } elseif ($this->logoAlign == 'R') {
602
                $nImgW = round($w / 3, 0);
603
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
604
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
605
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
606
                $x1 = $x;
607
                $y1 = round($h / 3 + $y, 0);
608
                $tw = round(2 * $w / 3, 0);
609
            }
610
            $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...
611
        } else {
612
            $x1 = $x;
613
            $y1 = round($h / 3 + $y, 0);
614
            $tw = $w;
615
        }
616
        //Nome emitente
617
        $aFont = array(
618
            'font' => $this->fontePadrao,
619
            'size' => 9,
620
            'style' => 'B');
621
        $texto = $this->pSimpleGetValue($this->emit, "xNome");
622
        $this->pTextBox($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...
623
        //endereço
624
        $y1 = $y1 + 3;
625
        $aFont = array(
626
            'font' => $this->fontePadrao,
627
            'size' => 7,
628
            'style' => '');
629
        $fone = $this->zFormatFone($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...
630
        $lgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
631
        $nro = $this->pSimpleGetValue($this->enderEmit, "nro");
632
        $cpl = $this->pSimpleGetValue($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...
633
        $bairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
634
        $CEP = $this->pSimpleGetValue($this->enderEmit, "CEP");
635
        $CEP = $this->pFormat($CEP, "#####-###");
636
        $mun = $this->pSimpleGetValue($this->enderEmit, "xMun");
637
        $UF = $this->pSimpleGetValue($this->enderEmit, "UF");
638
        $xPais = $this->pSimpleGetValue($this->enderEmit, "xPais");
639
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
640
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
641
            . "\n  Fone/Fax: " . $fone;
642
        $this->pTextBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
643
        //CNPJ/CPF IE
644
        $cpfCnpj = $this->zFormatCNPJCPF($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...
645
        $ie = $this->pSimpleGetValue($this->emit, "IE");
646
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
647
        $this->pTextBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
648
        //outra caixa
649
        $h1 = 17.5;
650
        $y1 = $y + $h + 1;
651
        $this->pTextBox($x, $y1, $w + 2, $h1);
652
        //TIPO DO CT-E
653
        $texto = 'TIPO DO CTE';
654
        $wa = 37;
655
        $aFont = array(
656
            'font' => $this->fontePadrao,
657
            'size' => 8,
658
            'style' => '');
659
        $this->pTextBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
660
        $tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
661
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
662
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
663
        switch ($tpCTe) {
664
            case '0':
665
                $texto = 'Normal';
666
                break;
667
            case '1':
668
                $texto = 'Complemento de Valores';
669
                break;
670
            case '2':
671
                $texto = 'Anulação de Valores';
672
                break;
673
            case '3':
674
                $texto = 'Substituto';
675
                break;
676
            default:
677
                $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...
678
        }
679
        $aFont = $this->formatNegrito;
680
        $this->pTextBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
681
        //TIPO DO SERVIÇO
682
        $texto = 'TIPO DO SERVIÇO';
683
        $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...
684
        $aFont = array(
685
            'font' => $this->fontePadrao,
686
            'size' => 8,
687
            'style' => '');
688
        $this->pTextBox($x + $wa + 4.5, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
689
        $tpServ = $this->pSimpleGetValue($this->ide, "tpServ");
690
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
691 View Code Duplication
        switch ($tpServ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
692
            case '0':
693
                $texto = 'Normal';
694
                break;
695
            case '1':
696
                $texto = 'Subcontratação';
697
                break;
698
            case '2':
699
                $texto = 'Redespacho';
700
                break;
701
            case '3':
702
                $texto = 'Redespacho Intermediário';
703
                break;
704
            default:
705
                $texto = 'ERRO' . $tpServ;
706
        }
707
        $aFont = $this->formatNegrito;
708
        $this->pTextBox($x + $wa + 4.5, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
709
        $this->pdf->Line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
710
        //TOMADOR DO SERVIÇO
711
        $texto = 'TOMADOR DO SERVIÇO';
712
        $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...
713
        $y2 = $y1 + 8;
714
        $aFont = array(
715
            'font' => $this->fontePadrao,
716
            'size' => 8,
717
            'style' => '');
718
        $this->pTextBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
719
        $this->pdf->Line($x, $y1 + 8, $w + 3, $y1 + 8);
720
        $toma = $this->pSimpleGetValue($this->ide, "toma");
721
        //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4 - Outros
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
722 View Code Duplication
        switch ($toma) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
723
            case '0':
724
                $texto = 'Remetente';
725
                break;
726
            case '1':
727
                $texto = 'Expedidor';
728
                break;
729
            case '2':
730
                $texto = 'Recebedor';
731
                break;
732
            case '3':
733
                $texto = 'Destinatário';
734
                break;
735
            case '4':
736
                $texto = 'Outros';
737
                break;
738
            default:
739
                $texto = 'ERRO' . $toma;
740
        }
741
        $aFont = $this->formatNegrito;
742
        $this->pTextBox($x, $y2 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
743
        //FORMA DE PAGAMENTO
744
        $texto = 'FORMA DE PAGAMENTO';
745
        $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...
746
        $aFont = array(
747
            'font' => $this->fontePadrao,
748
            'size' => 8,
749
            'style' => '');
750
        $this->pTextBox($x + $wa + 4.5, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
751
        $forma = $this->pSimpleGetValue($this->ide, "forPag");
752
        //0 - Pago;1 - A pagar;2 - outros
753
        switch ($forma) {
754
            case '0':
755
                $texto = 'Pago';
756
                break;
757
            case '1':
758
                $texto = 'A pagar';
759
                break;
760
            case '2':
761
                $texto = 'Outros';
762
                break;
763
            default:
764
                $texto = 'ERRO' . $forma;
765
        }
766
        $aFont = $this->formatNegrito;
767
        $this->pTextBox($x + $wa + 4.5, $y2 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
768
        //##################################################################
769
        //coluna direita
770
        $x += $w + 2;
771
        $w = round($maxW * 0.335);
772
        $w1 = $w;
773
        $h = 11;
774
        $this->pTextBox($x, $y, $w + 2, $h + 1);
775
        $texto = "DACTE";
776
        $aFont = array(
777
            'font' => $this->fontePadrao,
778
            'size' => 10,
779
            'style' => 'B');
780
        $this->pTextBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
781
        $aFont = array(
782
            'font' => $this->fontePadrao,
783
            'size' => 8,
784
            'style' => '');
785
        $texto = "Documento Auxiliar do Conhecimento\nde Transporte Eletrônico";
786
        $h = 10;
787
        $this->pTextBox($x, $y + 4, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
788
        $x1 = $x + $w + 2;
789
        $w = round($maxW * 0.22, 0);
790
        $w2 = $w;
791
        $h = 11;
792
        $this->pTextBox($x1, $y, $w + 0.5, $h + 1);
793
        $texto = "MODAL";
794
        $aFont = array(
795
            'font' => $this->fontePadrao,
796
            'size' => 8,
797
            'style' => '');
798
        $this->pTextBox($x1, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
799
        //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
800
        $modal = $this->pSimpleGetValue($this->ide, "modal");
801
        $this->modal = $modal;
802 View Code Duplication
        switch ($modal) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
803
            case '1':
804
                $texto = 'Rodoviário';
805
                break;
806
            case '2':
807
                $texto = 'Aéreo';
808
                break;
809
            case '3':
810
                $texto = 'Aquaviário';
811
                break;
812
            case '4':
813
                $texto = 'Ferroviário';
814
                break;
815
            case '5':
816
                $texto = 'Dutoviário';
817
                break;
818
        }
819
        $aFont = array(
820
            'font' => $this->fontePadrao,
821
            'size' => 10,
822
            'style' => 'B');
823
        $this->pTextBox($x1, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
824
        //outra caixa
825
        $y += 12;
826
        $h = 9;
827
        $w = $w1 + $w2 + 2;
828
        $this->pTextBox($x, $y, $w + 0.5, $h + 1);
829
        //modelo
830
        $wa = 12;
831
        $xa = $x;
832
        $texto = 'MODELO';
833
        $aFont = array(
834
            'font' => $this->fontePadrao,
835
            'size' => 8,
836
            'style' => '');
837
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
838
        $texto = $this->pSimpleGetValue($this->ide, "mod");
839
        $aFont = $this->formatNegrito;
840
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
841
        $this->pdf->Line($x + $wa, $y, $x + $wa, $y + $h + 1);
842
        //serie
843
        $xa += $wa;
844
        $texto = 'SÉRIE';
845
        $aFont = array(
846
            'font' => $this->fontePadrao,
847
            'size' => 8,
848
            'style' => '');
849
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
850
        $texto = $this->pSimpleGetValue($this->ide, "serie");
851
        $aFont = $this->formatNegrito;
852
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
853
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
854
        //numero
855
        $xa += $wa;
856
        $wa = 20;
857
        $texto = 'NÚMERO';
858
        $aFont = array(
859
            'font' => $this->fontePadrao,
860
            'size' => 8,
861
            'style' => '');
862
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
863
        $texto = $this->pSimpleGetValue($this->ide, "nCT");
864
        $aFont = $this->formatNegrito;
865
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
866
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
867
        //folha
868
        $xa += $wa;
869
        $wa = 12;
870
        $texto = 'FL';
871
        $aFont = array(
872
            'font' => $this->fontePadrao,
873
            'size' => 8,
874
            'style' => '');
875
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
876
        //$texto = '1/1';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
877
        $texto = $pag."/".$totPag;
878
        $aFont = $this->formatNegrito;
879
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
880
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
881
        //data  hora de emissão
882
        $xa += $wa;
883
        $wa = 30;
884
        $texto = 'DATA E HORA DE EMISSÃO';
885
        $aFont = array(
886
            'font' => $this->fontePadrao,
887
            'size' => 8,
888
            'style' => '');
889
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
890
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
891
            date('d/m/Y H:i:s', $this->pConvertTime($this->pSimpleGetValue($this->ide, "dhEmi"))) : '';
892
        $aFont = $this->formatNegrito;
893
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
894
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
895
        //ISUF
896
        $xa += $wa;
897
        $wa = 32;
898
        $texto = 'INSC. SUFRAMA DO DESTINATÁRIO';
899
        $aFont = $this->formatPadrao;
900
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
901
        $texto = $this->pSimpleGetValue($this->dest, "ISUF");
902
        $aFont = array(
903
            'font' => $this->fontePadrao,
904
            'size' => 7,
905
            'style' => 'B');
906
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
907
        //outra caixa
908
        $y += $h + 1;
909
        $h = 23;
910
        $h1 = 14;
911
        $this->pTextBox($x, $y, $w + 0.5, $h1);
912
        //CODIGO DE BARRAS
913
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
914
        $bW = 85;
915
        $bH = 10;
916
        //codigo de barras
917
        $this->pdf->SetFillColor(0, 0, 0);
918
        $this->pdf->Code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
919
        $this->pTextBox($x, $y + $h1, $w + 0.5, $h1 - 6);
920
        $texto = 'CHAVE DE ACESSO';
921
        $aFont = $this->formatPadrao;
922
        $this->pTextBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
923
        $aFont = $this->formatNegrito;
924
        $texto = $this->pFormat($chave_acesso, '##.####.##.###.###/####-##-##-###-###.###.###-###.###.###-#');
925
        $this->pTextBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
926
        $this->pTextBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
927
        $texto = "Consulta de autenticidade no portal nacional do CT-e, ";
928
        $texto .= "no site da Sefaz Autorizadora, \r\n ou em http://www.cte.fazenda.gov.br";
929
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
930
            $texto = "";
931
            $this->pdf->SetFillColor(0, 0, 0);
932
            if ($this->tpEmis == 5) {
933
                $chaveContingencia = $this->zGeraChaveAdicCont();
934
                $this->pdf->Code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
935
            } else {
936
                $chaveContingencia = $this->pSimpleGetValue($this->protCTe, "nProt");
937
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
938
            }
939
            //codigo de barras
940
        }
941
        $aFont = array(
942
            'font' => $this->fontePadrao,
943
            'size' => 8,
944
            'style' => '');
945
        $this->pTextBox($x, $y + $h1 + 9, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
946
        //outra caixa
947
        $y += $h + 1;
948
        $h = 8.5;
949
        $wa = $w;
950
        $this->pTextBox($x, $y + 7.5, $w + 0.5, $h);
951
        if ($this->zCteDPEC()) {
952
            $texto = 'NÚMERO DE REGISTRO DPEC';
953
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
954
            $texto = "DADOS DO CT-E";
955
        } else {
956
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
957
        }
958
        $aFont = $this->formatPadrao;
959
        $this->pTextBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
960
        if ($this->zCteDPEC()) {
961
            $texto = $this->numero_registro_dpec;
962
        } elseif ($this->tpEmis == 5) {
963
            $chaveContingencia = $this->zGeraChaveAdicCont();
964
            $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...
965
                'font' => $this->fontePadrao,
966
                'size' => 8,
967
                'style' => 'B');
968
            $texto = $this->pFormat($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
969
            $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...
970
        } else {
971
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") . " - ";
972
            // empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue)
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
973
            if (!empty($this->protCTe)
974
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
975
            ) {
976
                $texto .= date(
977
                    'd/m/Y   H:i:s',
978
                    $this->pConvertTime($this->pSimpleGetValue($this->protCTe, "dhRecbto"))
979
                );
980
            }
981
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") == '' ? '' : $texto;
982
        }
983
        $aFont = $this->formatNegrito;
984
        $this->pTextBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
985
        //CFOP
986
        $x = $oldX;
987
        $h = 8.5;
988
        $w = round($maxW * 0.42);
989
        $y1 = $y + 7.5;
990
        $this->pTextBox($x, $y1, $w + 2, $h);
991
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
992
        $aFont = array(
993
            'font' => $this->fontePadrao,
994
            'size' => 8,
995
            'style' => '');
996
        $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
997
        $texto = $this->pSimpleGetValue($this->ide, "CFOP") . ' - ' . $this->pSimpleGetValue($this->ide, "natOp");
998
        $aFont = $this->formatNegrito;
999
        $this->pTextBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1000
        //ORIGEM DA PRESTAÇÃO
1001
        $y += $h + 7.5;
1002
        $x = $oldX;
1003
        $h = 8;
1004
        $w = ($maxW * 0.5);
1005
        $this->pTextBox($x, $y, $w + 0.5, $h);
1006
        $texto = 'INÍCIO DA PRESTAÇÃO';
1007
        $aFont = array(
1008
            'font' => $this->fontePadrao,
1009
            'size' => 8,
1010
            'style' => '');
1011
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1012
        $texto = $this->pSimpleGetValue($this->ide, "xMunIni") . ' - ' . $this->pSimpleGetValue($this->ide, "UFIni");
1013
        $aFont = $this->formatNegrito;
1014
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1015
        //DESTINO DA PRESTAÇÃO
1016
        $x = $oldX + $w + 1;
1017
        $h = 8;
1018
        $w = $w - 1.3;
1019
        $this->pTextBox($x - 0.5, $y, $w + 0.5, $h);
1020
        $texto = 'TÉRMINO DA PRESTAÇÃO';
1021
        $aFont = array(
1022
            'font' => $this->fontePadrao,
1023
            'size' => 8,
1024
            'style' => '');
1025
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1026
        $texto = $this->pSimpleGetValue($this->ide, "xMunFim") . ' - ' . $this->pSimpleGetValue($this->ide, "UFFim");
1027
        $aFont = $this->formatNegrito;
1028
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1029
        //#########################################################################
1030
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
1031
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
1032
        //indicar cancelamento
1033
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1034
        if ($cStat == '101' || $cStat == '135' || $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_CANCELADA) {
1035
            //101 Cancelamento
1036
            $x = 10;
1037
            $y = $this->hPrint - 130;
1038
            $h = 25;
1039
            $w = $maxW - (2 * $x);
1040
            $this->pdf->SetTextColor(90, 90, 90);
1041
            $texto = "CTe CANCELADO";
1042
            $aFont = array(
1043
                'font' => $this->fontePadrao,
1044
                'size' => 48,
1045
                'style' => 'B');
1046
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1047
            $this->pdf->SetTextColor(0, 0, 0);
1048
        }
1049
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1050
        if ($cStat == '110' ||
1051
            $cStat == '301' ||
1052
            $cStat == '302' ||
1053
            $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_DENEGADA
1054
        ) {
1055
            //110 Denegada
1056
            $x = 10;
1057
            $y = $this->hPrint - 130;
1058
            $h = 25;
1059
            $w = $maxW - (2 * $x);
1060
            $this->pdf->SetTextColor(90, 90, 90);
1061
            $texto = "CTe USO DENEGADO";
1062
            $aFont = array(
1063
                'font' => $this->fontePadrao,
1064
                'size' => 48,
1065
                'style' => 'B');
1066
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1067
            $y += $h;
1068
            $h = 5;
1069
            $w = $maxW - (2 * $x);
1070
            $texto = "SEM VALOR FISCAL";
1071
            $aFont = array(
1072
                'font' => $this->fontePadrao,
1073
                'size' => 48,
1074
                'style' => 'B');
1075
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1076
            $this->pdf->SetTextColor(0, 0, 0);
1077
        }
1078
        //indicar sem valor
1079
        if ($tpAmb != 1 && $this->preVisualizar=='0') { // caso não seja uma DA de produção
1080
            $x = 10;
1081
            if ($this->orientacao == 'P') {
1082
                $y = round($this->hPrint * 2 / 3, 0);
1083
            } else {
1084
                $y = round($this->hPrint / 2, 0);
1085
            }
1086
            $h = 5;
1087
            $w = $maxW - (2 * $x);
1088
            $this->pdf->SetTextColor(90, 90, 90);
1089
            $texto = "SEM VALOR FISCAL";
1090
            $aFont = array(
1091
                'font' => $this->fontePadrao,
1092
                'size' => 48,
1093
                'style' => 'B');
1094
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1095
            $aFont = array(
1096
                'font' => $this->fontePadrao,
1097
                'size' => 30,
1098
                'style' => 'B');
1099
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1100
            $this->pTextBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1101
            $this->pdf->SetTextColor(0, 0, 0);
1102
        } elseif ($this->preVisualizar=='1') { // caso seja uma DA de Pré-Visualização
1103
            $h = 5;
1104
            $w = $maxW - (2 * 10);
1105
            $x = 55;
1106
            $y = 240;
1107
            $this->pdf->SetTextColor(255, 100, 100);
1108
            $aFont = array(
1109
                'font' => $this->fontePadrao,
1110
                'size' => 40,
1111
                'style' => 'B');
1112
            $texto = "Pré-visualização";
1113
            $this->pTextBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1114
            $this->pdf->SetTextColor(255, 100, 100);
1115
            $aFont = array(
1116
                'font' => $this->fontePadrao,
1117
                'size' => 41,
1118
                'style' => 'B');
1119
            $texto = "Sem Validade Jurídica";
1120
            $this->pTextBox90($x+20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1121
            $this->pdf->SetTextColor(90, 90, 90);
1122
            $texto = "SEM VALOR FISCAL";
1123
            $aFont = array(
1124
                'font' => $this->fontePadrao,
1125
                'size' => 48,
1126
                'style' => 'B');
1127
            $this->pTextBox90($x+40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1128
            $this->pdf->SetTextColor(0, 0, 0); // voltar a cor default
1129
        } else {
1130
            $x = 10;
1131
            if ($this->orientacao == 'P') {
1132
                $y = round($this->hPrint * 2 / 3, 0);
1133
            } else {
1134
                $y = round($this->hPrint / 2, 0);
1135
            } //fim orientacao
1136
            $h = 5;
1137
            $w = $maxW - (2 * $x);
1138
            $this->pdf->SetTextColor(90, 90, 90);
1139
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1140
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->zCteDPEC()) {
1141
                //Contingência
1142
                $texto = "DACTE Emitido em Contingência";
1143
                $aFont = array(
1144
                    'font' => $this->fontePadrao,
1145
                    'size' => 48,
1146
                    'style' => 'B');
1147
                $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1148
                $aFont = array(
1149
                    'font' => $this->fontePadrao,
1150
                    'size' => 30,
1151
                    'style' => 'B');
1152
                $texto = "devido à problemas técnicos";
1153
                $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1154
            } else {
1155 View Code Duplication
                if (!isset($this->cteProc)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1156
                    if (!$this->zCteDPEC()) {
1157
                        $texto = "SEM VALOR FISCAL";
1158
                        $aFont = array(
1159
                            'font' => $this->fontePadrao,
1160
                            'size' => 48,
1161
                            'style' => 'B');
1162
                        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1163
                    }
1164
                    $aFont = array(
1165
                        'font' => $this->fontePadrao,
1166
                        'size' => 30,
1167
                        'style' => 'B');
1168
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1169
                    if (!$this->zCteDPEC()) {
1170
                        $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1171
                    } else {
1172
                        $this->pTextBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1173
                    }
1174
                } //fim cteProc
1175 View Code Duplication
                if ($this->tpEmis == 4) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1176
                    //DPEC
1177
                    $x = 10;
1178
                    $y = $this->hPrint - 130;
1179
                    $h = 25;
1180
                    $w = $maxW - (2 * $x);
1181
                    $this->pdf->SetTextColor(200, 200, 200); // 90,90,90 é muito escuro
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1182
                    $texto = "DACTE impresso em contingência -\n"
1183
                        . "DPEC regularmente recebido pela Receita\n"
1184
                        . "Federal do Brasil";
1185
                    $aFont = array(
1186
                        'font' => $this->fontePadrao,
1187
                        'size' => 48,
1188
                        'style' => 'B');
1189
                    $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1190
                    $this->pdf->SetTextColor(0, 0, 0);
1191
                }
1192
            } //fim tpEmis
1193
            $this->pdf->SetTextColor(0, 0, 0);
1194
        }
1195
        return $oldY;
1196
    } //fim zCabecalho
1197
1198
    /**
1199
     * rodapeDACTE
1200
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1201
     *
1202
     * @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...
1203
     * @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...
1204
     */
1205
    protected function zRodape($x, $y)
1206
    {
1207
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1208
        $w = $this->wPrint - 4;
1209
        $aFont = array(
1210
            'font' => $this->fontePadrao,
1211
            'size' => 6,
1212
            'style' => '');
1213
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1214
        $texto = "DacteNFePHP ver. " . $this->version . "  Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org";
1215
        $aFont = array(
1216
            'font' => $this->fontePadrao,
1217
            'size' => 6,
1218
            'style' => '');
1219
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, 'http://www.nfephp.org');
1220
    } //fim zRodape
1221
1222
    /**
1223
     * zRemetente
1224
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1225
     *
1226
     * @param  number $x Posição horizontal canto esquerdo
1227
     * @param  number $y Posição vertical canto superior
1228
     * @return number Posição vertical final
1229
     */
1230
    protected function zRemetente($x = 0, $y = 0)
1231
    {
1232
        $oldX = $x;
1233
        $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...
1234 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1235
            $maxW = $this->wPrint;
1236
        } else {
1237
            $maxW = $this->wPrint - $this->wCanhoto;
1238
        }
1239
        $w = $maxW * 0.5 + 0.5;
1240
        $h = 19;
1241
        $x1 = $x + 16;
1242
        $texto = 'REMETENTE';
1243
        $aFont = $this->formatPadrao;
1244
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1245
        $aFont = $this->formatNegrito;
1246
        $texto = $this->pSimpleGetValue($this->rem, "xNome");
1247
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1248
        $y += 3;
1249
        $texto = 'ENDEREÇO';
1250
        $aFont = $this->formatPadrao;
1251
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1252
        $aFont = $this->formatNegrito;
1253
        $texto = $this->pSimpleGetValue($this->enderReme, "xLgr") . ',';
1254
        $texto .= $this->pSimpleGetValue($this->enderReme, "nro");
1255
        $texto .= ($this->pSimpleGetValue($this->enderReme, "xCpl") != "") ?
1256
            ' - ' . $this->pSimpleGetValue($this->enderReme, "xCpl") : '';
1257
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1258
        $y += 3;
1259
        $texto = $this->pSimpleGetValue($this->enderReme, "xBairro");
1260
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1261
        $y += 3;
1262
        $texto = 'MUNICÍPIO';
1263
        $aFont = $this->formatPadrao;
1264
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1265
        $texto = $this->pSimpleGetValue($this->enderReme, "xMun") . ' - ';
1266
        $texto .= $this->pSimpleGetValue($this->enderReme, "UF");
1267
        $aFont = $this->formatNegrito;
1268
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1269
        $x = $w - 18;
1270
        $texto = 'CEP';
1271
        $aFont = $this->formatPadrao;
1272
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1273
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReme, "CEP"), "#####-###");
1274
        $aFont = $this->formatNegrito;
1275
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1276
        $x = $oldX;
1277
        $y += 3;
1278
        $texto = 'CNPJ/CPF';
1279
        $aFont = $this->formatPadrao;
1280
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1281
        $cpfCnpj = $this->zFormatCNPJCPF($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...
1282
        $aFont = $this->formatNegrito;
1283
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1284
        $x = $w - 45;
1285
        $texto = 'INSCRIÇÃO ESTADUAL';
1286
        $aFont = $this->formatPadrao;
1287
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1288
        $texto = $this->pSimpleGetValue($this->rem, "IE");
1289
        $aFont = $this->formatNegrito;
1290
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1291
        $x = $oldX;
1292
        $y += 3;
1293
        $texto = 'PAÍS';
1294
        $aFont = $this->formatPadrao;
1295
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1296
        $texto = $this->pSimpleGetValue($this->rem, "xPais") != "" ?
1297
            $this->pSimpleGetValue($this->rem, "xPais") : 'BRASIL';
1298
        $aFont = $this->formatNegrito;
1299
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1300
        $x = $w - 25;
1301
        $texto = 'FONE';
1302
        $aFont = $this->formatPadrao;
1303
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1304
        $texto = $this->zFormatFone($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...
1305
        $aFont = $this->formatNegrito;
1306
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1307
    } //fim da função remetenteDACTE
1308
1309
    /**
1310
     * zDestinatario
1311
     * Monta o campo com os dados do destinatário na DACTE.
1312
     *
1313
     * @param  number $x Posição horizontal canto esquerdo
1314
     * @param  number $y Posição vertical canto superior
1315
     * @return number Posição vertical final
1316
     */
1317
    protected function zDestinatario($x = 0, $y = 0)
1318
    {
1319
        $oldX = $x;
1320
        $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...
1321 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1322
            $maxW = $this->wPrint;
1323
        } else {
1324
            $maxW = $this->wPrint - $this->wCanhoto;
1325
        }
1326
        $w = ($maxW * 0.5) - 0.7;
1327
        $h = 19;
1328
        $x1 = $x + 19;
1329
        $texto = 'DESTINATÁRIO';
1330
        $aFont = $this->formatPadrao;
1331
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1332
        $aFont = $this->formatNegrito;
1333
        $texto = $this->pSimpleGetValue($this->dest, "xNome");
1334
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1335
        $y += 3;
1336
        $texto = 'ENDEREÇO';
1337
        $aFont = $this->formatPadrao;
1338
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1339
        $aFont = $this->formatNegrito;
1340
        $texto = $this->pSimpleGetValue($this->enderDest, "xLgr") . ',';
1341
        $texto .= $this->pSimpleGetValue($this->enderDest, "nro");
1342
        $texto .= $this->pSimpleGetValue($this->enderDest, "xCpl") != "" ?
1343
            ' - ' . $this->pSimpleGetValue($this->enderDest, "xCpl") : '';
1344
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1345
        $y += 3;
1346
        $texto = $this->pSimpleGetValue($this->enderDest, "xBairro");
1347
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1348
        $y += 3;
1349
        $texto = 'MUNICÍPIO';
1350
        $aFont = $this->formatPadrao;
1351
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1352
        $texto = $this->pSimpleGetValue($this->enderDest, "xMun") . ' - ';
1353
        $texto .= $this->pSimpleGetValue($this->enderDest, "UF");
1354
        $aFont = $this->formatNegrito;
1355
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1356
        $x = $w - 19 + $oldX;
1357
        $texto = 'CEP';
1358
        $aFont = $this->formatPadrao;
1359
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1360
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderDest, "CEP"), "#####-###");
1361
        $aFont = $this->formatNegrito;
1362
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1363
        $x = $oldX;
1364
        $y += 3;
1365
        $texto = 'CNPJ/CPF';
1366
        $aFont = $this->formatPadrao;
1367
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1368
        $cpfCnpj = $this->zFormatCNPJCPF($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...
1369
        $aFont = $this->formatNegrito;
1370
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1371
        $x = $w - 47.5 + $oldX;
1372
        $texto = 'INSCRIÇÃO ESTADUAL';
1373
        $aFont = $this->formatPadrao;
1374
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1375
        $texto = $this->pSimpleGetValue($this->dest, "IE");
1376
        $aFont = $this->formatNegrito;
1377
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1378
        $x = $oldX;
1379
        $y += 3;
1380
        $texto = 'PAÍS';
1381
        $aFont = $this->formatPadrao;
1382
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1383
        $texto = $this->pSimpleGetValue($this->dest, "xPais");
1384
        $aFont = $this->formatNegrito;
1385
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1386
        $x = $w - 27 + $oldX;
1387
        $texto = 'FONE';
1388
        $aFont = $this->formatPadrao;
1389
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1390
        $texto = $this->zFormatFone($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...
1391
        $aFont = $this->formatNegrito;
1392
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1393
    } //fim da função destinatarioDACTE
1394
1395
    /**
1396
     * zExpedidor
1397
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1398
     *
1399
     * @param  number $x Posição horizontal canto esquerdo
1400
     * @param  number $y Posição vertical canto superior
1401
     * @return number Posição vertical final
1402
     */
1403
    protected function zExpedidor($x = 0, $y = 0)
1404
    {
1405
        $oldX = $x;
1406
        $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...
1407 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1408
            $maxW = $this->wPrint;
1409
        } else {
1410
            $maxW = $this->wPrint - $this->wCanhoto;
1411
        }
1412
        $w = $maxW * 0.5 + 0.5;
1413
        $h = 19;
1414
        $x1 = $x + 16;
1415
        $texto = 'EXPEDIDOR';
1416
        $aFont = $this->formatPadrao;
1417
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1418
        $aFont = $this->formatNegrito;
1419
        $texto = $this->pSimpleGetValue($this->exped, "xNome");
1420
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1421
        $y += 3;
1422
        $texto = 'ENDEREÇO';
1423
        $aFont = $this->formatPadrao;
1424
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1425
        $aFont = $this->formatNegrito;
1426 View Code Duplication
        if (isset($this->enderExped)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1427
            $texto = $this->pSimpleGetValue($this->enderExped, "xLgr") . ', ';
1428
            $texto .= $this->pSimpleGetValue($this->enderExped, "nro");
1429
            $texto .= $this->pSimpleGetValue($this->enderExped, "xCpl") != "" ?
1430
                ' - ' . $this->pSimpleGetValue($this->enderExped, "xCpl") :
1431
                '';
1432
        } else {
1433
            $texto = '';
1434
        }
1435
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1436
        $y += 3;
1437
        $texto = $this->pSimpleGetValue($this->enderExped, "xBairro");
1438
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1439
        $y += 3;
1440
        $texto = 'MUNICÍPIO';
1441
        $aFont = $this->formatPadrao;
1442
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1443 View Code Duplication
        if (isset($this->enderExped)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1444
            $texto = $this->pSimpleGetValue($this->enderExped, "xMun") . ' - ';
1445
            $texto .= $this->pSimpleGetValue($this->enderExped, "UF");
1446
        } else {
1447
            $texto = '';
1448
        }
1449
        $aFont = $this->formatNegrito;
1450
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1451
        $x = $w - 18;
1452
        $texto = 'CEP';
1453
        $aFont = $this->formatPadrao;
1454
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1455
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderExped, "CEP"), "#####-###");
1456
        $aFont = $this->formatNegrito;
1457
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1458
        $x = $oldX;
1459
        $y += 3;
1460
        $texto = 'CNPJ/CPF';
1461
        $aFont = $this->formatPadrao;
1462
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1463
        $cpfCnpj = $this->zFormatCNPJCPF($this->exped);
1464
        $aFont = $this->formatNegrito;
1465
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1466
        $x = $w - 45;
1467
        $texto = 'INSCRIÇÃO ESTADUAL';
1468
        $aFont = $this->formatPadrao;
1469
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1470
        $texto = $this->pSimpleGetValue($this->exped, "IE");
1471
        $aFont = $this->formatNegrito;
1472
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1473
        $x = $oldX;
1474
        $y += 3;
1475
        $texto = 'PAÍS';
1476
        $aFont = $this->formatPadrao;
1477
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1478
        $texto = $this->pSimpleGetValue($this->exped, "xPais");
1479
        $aFont = $this->formatNegrito;
1480
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1481
        $x = $w - 25;
1482
        $texto = 'FONE';
1483
        $aFont = $this->formatPadrao;
1484
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1485 View Code Duplication
        if (isset($this->exped)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1486
            $texto = $this->zFormatFone($this->exped);
1487
            $aFont = $this->formatNegrito;
1488
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1489
        }
1490
    } //fim da função remetenteDACTE
1491
1492
    /**
1493
     * zRecebedor
1494
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1495
     *
1496
     * @param  number $x Posição horizontal canto esquerdo
1497
     * @param  number $y Posição vertical canto superior
1498
     * @return number Posição vertical final
1499
     */
1500
    protected function zRecebedor($x = 0, $y = 0)
1501
    {
1502
        $oldX = $x;
1503
        $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...
1504 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1505
            $maxW = $this->wPrint;
1506
        } else {
1507
            $maxW = $this->wPrint - $this->wCanhoto;
1508
        }
1509
        $w = ($maxW * 0.5) - 0.7;
1510
        $h = 19;
1511
        $x1 = $x + 19;
1512
        $texto = 'RECEBEDOR';
1513
        $aFont = $this->formatPadrao;
1514
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1515
        $aFont = $this->formatNegrito;
1516
        $texto = $this->pSimpleGetValue($this->receb, "xNome");
1517
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1518
        $y += 3;
1519
        $texto = 'ENDEREÇO';
1520
        $aFont = $this->formatPadrao;
1521
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1522
        $aFont = $this->formatNegrito;
1523 View Code Duplication
        if (isset($this->enderReceb)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1524
            $texto = $this->pSimpleGetValue($this->enderReceb, "xLgr") . ', ';
1525
            $texto .= $this->pSimpleGetValue($this->enderReceb, "nro");
1526
            $texto .= ($this->pSimpleGetValue($this->enderReceb, "xCpl") != "") ?
1527
                ' - ' . $this->pSimpleGetValue($this->enderReceb, "xCpl") :
1528
                '';
1529
        } else {
1530
            $texto = '';
1531
        }
1532
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1533
        $y += 3;
1534
        $texto = $this->pSimpleGetValue($this->enderReceb, "xBairro");
1535
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1536
        $y += 3;
1537
        $texto = 'MUNICÍPIO';
1538
        $aFont = $this->formatPadrao;
1539
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1540 View Code Duplication
        if (isset($this->enderReceb)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1541
            $texto = $this->pSimpleGetValue($this->enderReceb, "xMun") . ' - ';
1542
            $texto .= $this->pSimpleGetValue($this->enderReceb, "UF");
1543
        } else {
1544
            $texto = '';
1545
        }
1546
        $aFont = $this->formatNegrito;
1547
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1548
        $x = $w - 19 + $oldX;
1549
        $texto = 'CEP';
1550
        $aFont = $this->formatPadrao;
1551
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1552
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReceb, "CEP"), "#####-###");
1553
        $aFont = $this->formatNegrito;
1554
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1555
        $x = $oldX;
1556
        $y += 3;
1557
        $texto = 'CNPJ/CPF';
1558
        $aFont = $this->formatPadrao;
1559
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1560
        $texto = $this->zFormatCNPJCPF($this->receb);
1561
        $aFont = $this->formatNegrito;
1562
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1563
        $x = $w - 47 + $oldX;
1564
        $texto = 'INSCRIÇÃO ESTADUAL';
1565
        $aFont = $this->formatPadrao;
1566
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1567
        $texto = $this->pSimpleGetValue($this->receb, "IE");
1568
        $aFont = $this->formatNegrito;
1569
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1570
        $x = $oldX;
1571
        $y += 3;
1572
        $texto = 'PAÍS';
1573
        $aFont = $this->formatPadrao;
1574
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1575
        $texto = $this->pSimpleGetValue($this->receb, "xPais");
1576
        $aFont = $this->formatNegrito;
1577
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1578
        $x = $w - 27 + $oldX;
1579
        $texto = 'FONE';
1580
        $aFont = $this->formatPadrao;
1581
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1582 View Code Duplication
        if (isset($this->receb)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1583
            $texto = $this->zFormatFone($this->receb);
1584
            $aFont = $this->formatNegrito;
1585
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1586
        }
1587
    } //fim da função recebedorDACTE
1588
1589
    /**
1590
     * zTomador
1591
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1592
     *
1593
     * @param  number $x Posição horizontal canto esquerdo
1594
     * @param  number $y Posição vertical canto superior
1595
     * @return number Posição vertical final
1596
     */
1597
    protected function zTomador($x = 0, $y = 0)
1598
    {
1599
        $oldX = $x;
1600
        $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...
1601 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1602
            $maxW = $this->wPrint;
1603
        } else {
1604
            $maxW = $this->wPrint - $this->wCanhoto;
1605
        }
1606
        $w = $maxW;
1607
        $h = 10;
1608
        $texto = 'TOMADOR DO SERVIÇO';
1609
        $aFont = $this->formatPadrao;
1610
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1611
        $aFont = $this->formatNegrito;
1612
        $texto = $this->pSimpleGetValue($this->toma, "xNome");
1613
        $this->pTextBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1614
        $x = $maxW * 0.60;
1615
        $texto = 'MUNICÍPIO';
1616
        $aFont = $this->formatPadrao;
1617
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1618
        $texto = $this->pSimpleGetValue($this->toma, "xMun");
1619
        $aFont = $this->formatNegrito;
1620
        $this->pTextBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1621
        $x = $maxW * 0.85;
1622
        $texto = 'UF';
1623
        $aFont = $this->formatPadrao;
1624
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1625
        $texto = $this->pSimpleGetValue($this->toma, "UF");
1626
        $aFont = $this->formatNegrito;
1627
        $this->pTextBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1628
        $x = $w - 18;
1629
        $texto = 'CEP';
1630
        $aFont = $this->formatPadrao;
1631
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1632
        $texto = $this->pFormat($this->pSimpleGetValue($this->toma, "CEP"), "#####-###");
1633
        $aFont = $this->formatNegrito;
1634
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1635
        $y += 3;
1636
        $x = $oldX;
1637
        $texto = 'ENDEREÇO';
1638
        $aFont = $this->formatPadrao;
1639
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1640
        $aFont = $this->formatNegrito;
1641
        $texto = $this->pSimpleGetValue($this->toma, "xLgr") . ',';
1642
        $texto .= $this->pSimpleGetValue($this->toma, "nro");
1643
        $texto .= ($this->pSimpleGetValue($this->toma, "xCpl") != "") ?
1644
            ' - ' . $this->pSimpleGetValue($this->toma, "xCpl") : '';
1645
        $texto .= ' - ' . $this->pSimpleGetValue($this->toma, "xBairro");
1646
        $this->pTextBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1647
        $y += 3;
1648
        $texto = 'CNPJ/CPF';
1649
        $aFont = $this->formatPadrao;
1650
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1651
        $texto = $this->zFormatCNPJCPF($this->toma);
1652
        $aFont = $this->formatNegrito;
1653
        $this->pTextBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1654
        $x = $x + 65;
1655
        $texto = 'INSCRIÇÃO ESTADUAL';
1656
        $aFont = $this->formatPadrao;
1657
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1658
        $texto = $this->pSimpleGetValue($this->toma, "IE");
1659
        $aFont = $this->formatNegrito;
1660
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1661
        $x = $w * 0.75;
1662
        $texto = 'PAÍS';
1663
        $aFont = $this->formatPadrao;
1664
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1665
        $texto = $this->pSimpleGetValue($this->toma, "xPais") != "" ?
1666
            $this->pSimpleGetValue($this->toma, "xPais") : 'BRASIL';
1667
        $aFont = $this->formatNegrito;
1668
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1669
        $x = $w - 27;
1670
        $texto = 'FONE';
1671
        $aFont = $this->formatPadrao;
1672
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1673
        $texto = $this->zFormatFone($this->toma);
1674
        $aFont = $this->formatNegrito;
1675
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1676
    } //fim da função tomadorDACTE
1677
1678
    /**
1679
     * zDescricaoCarga
1680
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1681
     *
1682
     * @param  number $x Posição horizontal canto esquerdo
1683
     * @param  number $y Posição vertical canto superior
1684
     * @return number Posição vertical final
1685
     */
1686
    protected function zDescricaoCarga($x = 0, $y = 0)
1687
    {
1688
        $oldX = $x;
1689
        $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...
1690 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1691
            $maxW = $this->wPrint;
1692
        } else {
1693
            $maxW = $this->wPrint - $this->wCanhoto;
1694
        }
1695
        $w = $maxW;
1696
        $h = 17;
1697
        $texto = 'PRODUTO PREDOMINANTE';
1698
        $aFont = array(
1699
            'font' => $this->fontePadrao,
1700
            'size' => 6,
1701
            'style' => '');
1702
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1703
        $texto = $this->pSimpleGetValue($this->infCarga, "proPred");
1704
        $aFont = $this->formatNegrito;
1705
        $this->pTextBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1706
        $x = $w * 0.56;
1707
        $this->pdf->Line($x, $y, $x, $y + 8);
1708
        $aFont = $this->formatPadrao;
1709
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1710
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1711
        $texto = $this->pSimpleGetValue($this->infCarga, "xOutCat");
1712
        $aFont = $this->formatNegrito;
1713
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1714
        $x = $w * 0.8;
1715
        $this->pdf->Line($x, $y, $x, $y + 8);
1716
        $aFont = $this->formatPadrao;
1717
        $texto = 'VALOR TOTAL DA MERCADORIA';
1718
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1719
        $texto = $this->pSimpleGetValue($this->infCarga, "vCarga") == "" ?
1720
            $this->pSimpleGetValue($this->infCarga, "vMerc") : $this->pSimpleGetValue($this->infCarga, "vCarga");
1721
        $texto = number_format($texto, 2, ",", ".");
1722
        $aFont = $this->formatNegrito;
1723
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1724
        $y += 8;
1725
        $x = $oldX;
1726
        $this->pdf->Line($x, $y, $w + 1, $y);
1727
        $texto = 'TP MED /UN. MED';
1728
        $aFont = array(
1729
            'font' => $this->fontePadrao,
1730
            'size' => 5,
1731
            'style' => '');
1732
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1733
        $texto = $this->pSimpleGetValue($this->infQ->item(0), "tpMed") . "\r\n";
1734
        $texto .= number_format(
1735
            $this->pSimpleGetValue(
1736
                $this->infQ->item(0),
1737
                "qCarga"
1738
            )
1739
            / $this->zMultiUniPeso(
1740
                $this->pSimpleGetValue(
1741
                    $this->infQ->item(0),
1742
                    "cUnid"
1743
                )
1744
            ),
1745
            3,
1746
            ".",
1747
            ""
1748
        );
1749
        $texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(0), "cUnid"));
1750
        $aFont = array(
1751
            'font' => $this->fontePadrao,
1752
            'size' => 7,
1753
            'style' => 'B');
1754
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1755
        $x = $w * 0.12;
1756
        $this->pdf->Line($x, $y, $x, $y + 9);
1757
        $texto = 'TP MED /UN. MED';
1758
        $aFont = array(
1759
            'font' => $this->fontePadrao,
1760
            'size' => 5,
1761
            'style' => '');
1762
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1763
        $texto = $this->pSimpleGetValue($this->infQ->item(1), "tpMed") . "\r\n";
1764
        $texto .= number_format(
1765
            $this->pSimpleGetValue(
1766
                $this->infQ->item(1),
1767
                "qCarga"
1768
            )
1769
            / $this->zMultiUniPeso(
1770
                $this->pSimpleGetValue($this->infQ->item(1), "cUnid")
1771
            ),
1772
            3,
1773
            ".",
1774
            ""
1775
        );
1776
        $texto = $this->pSimpleGetValue($this->infQ->item(1), "qCarga") == '' ? '' : $texto;
1777
        $texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(1), "cUnid"));
1778
        $aFont = array(
1779
            'font' => $this->fontePadrao,
1780
            'size' => 7,
1781
            'style' => 'B');
1782
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1783
        $x = $w * 0.24;
1784
        $this->pdf->Line($x, $y, $x, $y + 9);
1785
        $texto = 'TP MED /UN. MED';
1786
        $aFont = array(
1787
            'font' => $this->fontePadrao,
1788
            'size' => 5,
1789
            'style' => '');
1790
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1791
        $texto = $this->pSimpleGetValue($this->infQ->item(2), "tpMed") . "\r\n";
1792
        $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
1793
        $texto .= !empty($qCarga) ?
1794
            number_format(
1795
                $qCarga
1796
                / $this->zMultiUniPeso(
1797
                    $this->pSimpleGetValue($this->infQ->item(2), "cUnid")
1798
                ),
1799
                3,
1800
                ".",
1801
                ""
1802
            ) :
1803
            '';
1804
        $texto = $this->pSimpleGetValue($this->infQ->item(2), "qCarga") == '' ? '' : $texto;
1805
        $texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(2), "cUnid"));
1806
        $aFont = array(
1807
            'font' => $this->fontePadrao,
1808
            'size' => 7,
1809
            'style' => 'B');
1810
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1811
        $x = $w * 0.36;
1812
        $this->pdf->Line($x, $y, $x, $y + 9);
1813
        $texto = 'CUBAGEM(M3)';
1814
        $aFont = $this->formatPadrao;
1815
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1816
        if ($this->pSimpleGetValue($this->infQ->item(0), "cUnid") == '00') {
1817
            $qCarga = $this->pSimpleGetValue($this->infQ->item(0), "qCarga");
1818
            $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1819
        } else {
1820
            $texto = '';
1821
        }
1822
        $aFont = array(
1823
            'font' => $this->fontePadrao,
1824
            'size' => 7,
1825
            'style' => 'B');
1826
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1827
        $x = $w * 0.45;
1828
        $this->pdf->Line($x, $y, $x, $y + 9);
1829
        $texto = 'QTDE(VOL)';
1830
        $aFont = $this->formatPadrao;
1831
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1832
        $qCarga = $this->pSimpleGetValue($this->infQ->item(3), "qCarga");
1833
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1834
        $aFont = array(
1835
            'font' => $this->fontePadrao,
1836
            'size' => 7,
1837
            'style' => 'B');
1838
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1839
        $x = $w * 0.53;
1840
        $this->pdf->Line($x, $y, $x, $y + 9);
1841
        $texto = 'NOME DA SEGURADORA';
1842
        $aFont = $this->formatPadrao;
1843
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1844
        $texto = $this->pSimpleGetValue($this->seg, "xSeg");
1845
        $aFont = array(
1846
            'font' => $this->fontePadrao,
1847
            'size' => 7,
1848
            'style' => 'B');
1849
        $this->pTextBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1850
        $y += 3;
1851
        $this->pdf->Line($x, $y, $w + 1, $y);
1852
        $texto = 'RESPONSÁVEL';
1853
        $aFont = $this->formatPadrao;
1854
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1855
        $texto = $this->respSeg;
1856
        $aFont = array(
1857
            'font' => $this->fontePadrao,
1858
            'size' => 7,
1859
            'style' => 'B');
1860
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1861
        $x = $w * 0.68;
1862
        $this->pdf->Line($x, $y, $x, $y + 6);
1863
        $texto = 'NÚMERO DA APOLICE';
1864
        $aFont = $this->formatPadrao;
1865
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1866
        $texto = $this->pSimpleGetValue($this->seg, "nApol");
1867
        $aFont = array(
1868
            'font' => $this->fontePadrao,
1869
            'size' => 7,
1870
            'style' => 'B');
1871
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1872
        $x = $w * 0.85;
1873
        $this->pdf->Line($x, $y, $x, $y + 6);
1874
        $texto = 'NÚMERO DA AVERBAÇÃO';
1875
        $aFont = $this->formatPadrao;
1876
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1877
        $texto = $this->pSimpleGetValue($this->seg, "nAver");
1878
        $aFont = array(
1879
            'font' => $this->fontePadrao,
1880
            'size' => 7,
1881
            'style' => 'B');
1882
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1883
    } //fim da função zDescricaoCarga
1884
1885
    /**
1886
     * zCompValorServ
1887
     * Monta o campo com os componentes da prestação de serviços.
1888
     *
1889
     * @param  number $x Posição horizontal canto esquerdo
1890
     * @param  number $y Posição vertical canto superior
1891
     * @return number Posição vertical final
1892
     */
1893
    protected function zCompValorServ($x = 0, $y = 0)
1894
    {
1895
        $oldX = $x;
1896
        $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...
1897 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1898
            $maxW = $this->wPrint;
1899
        } else {
1900
            $maxW = $this->wPrint - $this->wCanhoto;
1901
        }
1902
        $w = $maxW;
1903
        $h = 25;
1904
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1905
        $aFont = $this->formatPadrao;
1906
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1907
        $y += 3.4;
1908
        $this->pdf->Line($x, $y, $w + 1, $y);
1909
        $texto = 'NOME';
1910
        $aFont = $this->formatPadrao;
1911
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1912
        $yIniDados = $y;
1913
        $x = $w * 0.14;
1914
        $texto = 'VALOR';
1915
        $aFont = $this->formatPadrao;
1916
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1917
        $x = $w * 0.28;
1918
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1919
        $texto = 'NOME';
1920
        $aFont = $this->formatPadrao;
1921
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1922
        $x = $w * 0.42;
1923
        $texto = 'VALOR';
1924
        $aFont = $this->formatPadrao;
1925
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1926
        $x = $w * 0.56;
1927
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1928
        $texto = 'NOME';
1929
        $aFont = $this->formatPadrao;
1930
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1931
        $x = $w * 0.70;
1932
        $texto = 'VALOR';
1933
        $aFont = $this->formatPadrao;
1934
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1935
        $x = $w * 0.86;
1936
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1937
        $y += 1;
1938
        $texto = 'VALOR TOTAL DO SERVIÇO';
1939
        $aFont = $this->formatPadrao;
1940
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1941
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
1942
        $aFont = array(
1943
            'font' => $this->fontePadrao,
1944
            'size' => 9,
1945
            'style' => 'B');
1946
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1947
        $y += 10;
1948
        $this->pdf->Line($x, $y, $w + 1, $y);
1949
        $y += 1;
1950
        $texto = 'VALOR A RECEBER';
1951
        $aFont = $this->formatPadrao;
1952
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1953
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, ",", ".");
1954
        $aFont = array(
1955
            'font' => $this->fontePadrao,
1956
            'size' => 9,
1957
            'style' => 'B');
1958
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1959
        $auxX = $oldX;
1960
        $yIniDados += 4;
1961
        foreach ($this->Comp as $k => $d) {
1962
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1963
            $valor = number_format(
1964
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1965
                2,
1966
                ",",
1967
                "."
1968
            );
1969
            if ($auxX > $w * 0.60) {
1970
                $yIniDados = $yIniDados + 4;
1971
                $auxX = $oldX;
1972
            }
1973
            $texto = $nome;
1974
            $aFont = $this->formatPadrao;
1975
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1976
            $auxX += $w * 0.14;
1977
            $texto = $valor;
1978
            $aFont = $this->formatPadrao;
1979
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1980
            $auxX += $w * 0.14;
1981
        }
1982
    } //fim da função compValorDACTE
1983
1984
    /**
1985
     * zImpostos
1986
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1987
     *
1988
     * @param  number $x Posição horizontal canto esquerdo
1989
     * @param  number $y Posição vertical canto superior
1990
     * @return number Posição vertical final
1991
     */
1992
    protected function zImpostos($x = 0, $y = 0)
1993
    {
1994
        $oldX = $x;
1995
        $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...
1996 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1997
            $maxW = $this->wPrint;
1998
        } else {
1999
            $maxW = $this->wPrint - $this->wCanhoto;
2000
        }
2001
        $w = $maxW;
2002
        $h = 13;
2003
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
2004
        $aFont = $this->formatPadrao;
2005
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2006
        
2007
        $y += 3.4;
2008
        $this->pdf->Line($x, $y, $w + 1, $y);
2009
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
2010
        $aFont = $this->formatPadrao;
2011
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2012
        
2013
        $x += $w * 0.26;
2014
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2015
        $texto = 'BASE DE CALCULO';
2016
        $aFont = $this->formatPadrao;
2017
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2018
        
2019
        $wCol02=0.18;
2020
        $x += $w * $wCol02;
2021
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2022
        $texto = 'ALÍQ ICMS';
2023
        $aFont = $this->formatPadrao;
2024
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2025
        
2026
        $x += $w * $wCol02;
2027
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2028
        $texto = 'VALOR ICMS';
2029
        $aFont = $this->formatPadrao;
2030
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2031
        
2032
        $x += $w * $wCol02;
2033
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2034
        $texto = '% RED. BC ICMS';
2035
        $aFont = $this->formatPadrao;
2036
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2037
        
2038
        /*$x += $w * 0.14;
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2039
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2040
        $texto = 'ICMS ST';
2041
        $aFont = $this->formatPadrao;
2042
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2043
         * */
2044
        
2045
        $x = $oldX;
2046
        $y = $y + 4;
2047
        $texto = $this->pSimpleGetValue($this->ICMS, "CST");
2048
        switch ($texto) {
2049
            case '00':
2050
                $texto = "00 - Tributação normal ICMS";
2051
                break;
2052
            case '20':
2053
                $texto = "20 - Tributação com BC reduzida do ICMS";
2054
                break;
2055
            case '40':
2056
                $texto = "40 - ICMS isenção";
2057
                break;
2058
            case '41':
2059
                $texto = "41 - ICMS não tributada";
2060
                break;
2061
            case '51':
2062
                $texto = "51 - ICMS diferido";
2063
                break;
2064
            case '60':
2065
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
2066
                break;
2067
            case '90':
2068
                $texto = "90 - ICMS outros";
2069
                break;
2070
        }
2071
        $texto .= $this->pSimpleGetValue($this->ICMSSN, "indSN");
2072
        $texto = $texto == 1 ? 'Simples Nacional' : $texto;
2073
        $aFont = $this->formatNegrito;
2074
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2075
        $x += $w * 0.26;
2076
        
2077
        $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2078
            number_format($this->pSimpleGetValue($this->ICMS, "vBC"), 2, ",", ".") : '';
2079
        $aFont = $this->formatNegrito;
2080
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2081
        $x += $w * $wCol02;
2082
        
2083
        $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2084
            number_format($this->pSimpleGetValue($this->ICMS, "pICMS"), 2, ",", ".") : '';
2085
        $aFont = $this->formatNegrito;
2086
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2087
        $x += $w * $wCol02;
2088
        
2089
        $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2090
            number_format($this->pSimpleGetValue($this->ICMS, "vICMS"), 2, ",", ".") : '';
2091
        $aFont = $this->formatNegrito;
2092
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2093
        $x += $w * $wCol02;
2094
        
2095
        $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2096
            number_format($this->pSimpleGetValue($this->ICMS, "pRedBC"), 2, ",", ".").'%' :'';
2097
        $aFont = $this->formatNegrito;
2098
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2099
        
2100
        /*$x += $w * 0.14;
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2101
        $texto = '';
2102
        $aFont = $this->formatNegrito;
2103
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2104
    } //fim da função compValorDACTE
2105
2106
    /**
2107
     * zGeraChaveAdicCont
2108
     *
2109
     * @return string chave
2110
     */
2111
    protected function zGeraChaveAdicCont()
2112
    {
2113
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2114
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2115
        $forma = "%02d%d%s%014d%01d%01d%02d";
2116
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2117
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2118
        $CNPJ = substr($CNPJ, -14);
2119
        $vCT = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, "", "") * 100;
2120
        $ICMS_CST = $this->pSimpleGetValue($this->ICMS, "CST");
2121
        switch ($ICMS_CST) {
2122
            case '00':
2123
            case '20':
2124
                $ICMSp = '1';
2125
                $ICMSs = '2';
2126
                break;
2127
            case '40':
2128
            case '41':
2129
            case '51':
2130
            case '90':
2131
                $ICMSp = '2';
2132
                $ICMSs = '2';
2133
                break;
2134
            case '60':
2135
                $ICMSp = '2';
2136
                $ICMSs = '1';
2137
                break;
2138
        }
2139
        $dd = $this->ide->getElementsByTagName('dEmi')->item(0)->nodeValue;
2140
        $rpos = strrpos($dd, '-');
2141
        $dd = substr($dd, $rpos + 1);
2142
        $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...
2143
        $chave = $chave . $this->pModulo11($chave);
2144
        return $chave;
2145
    } //fim zGeraChaveAdicCont
2146
2147
    /**
2148
     * zDocOrig
2149
     * Monta o campo com os documentos originarios.
2150
     *
2151
     * @param  number $x Posição horizontal canto esquerdo
2152
     * @param  number $y Posição vertical canto superior
2153
     * @return number Posição vertical final
2154
     */
2155
    protected function zDocOrig($x = 0, $y = 0)
2156
    {
2157
        $oldX = $x;
2158
        $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...
2159 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2160
            $maxW = $this->wPrint;
2161
        } else {
2162
            $maxW = $this->wPrint - $this->wCanhoto;
2163
        }
2164
        $w = $maxW;
2165
        
2166
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2167 View Code Duplication
        if ($this->modal == '1') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2168
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2169
            // ou combinação veicular, e por viagem
2170
            $h = $this->lota == 1 ? 35 : 53;
2171
        } elseif ($this->modal == '3') {
2172
            $h = 37.6;
2173
        } else {
2174
            $h = 35;
2175
        }
2176
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2177
        $aFont = $this->formatPadrao;
2178
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2179
        $descr1 = 'TIPO DOC';
2180
        $descr2 = 'CNPJ/CHAVE/OBS';
2181
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2182
        
2183
        $y += 3.4;
2184
        $this->pdf->Line($x, $y, $w + 1, $y);
2185
        $texto = $descr1;
2186
        $aFont = $this->formatPadrao;
2187
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2188
        $yIniDados = $y;
2189
        
2190
        $x += $w * 0.07;
2191
        $texto = $descr2;
2192
        $aFont = $this->formatPadrao;
2193
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2194
        
2195
        $x += $w * 0.28;
2196
        $texto = $descr3;
2197
        $aFont = $this->formatPadrao;
2198
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2199
        
2200
        $x += $w * 0.14;
2201 View Code Duplication
        if ($this->modal == '1') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2202
            if ($this->lota == 1) {
2203
                $this->pdf->Line($x, $y, $x, $y + 31.5);
2204
            } else {
2205
                $this->pdf->Line($x, $y, $x, $y + 49.5);
2206
            }
2207
        } elseif ($this->modal == '3') {
2208
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2209
        } else {
2210
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2211
        }
2212
        $texto = $descr1;
2213
        $aFont = $this->formatPadrao;
2214
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2215
        
2216
        $x += $w * 0.08;
2217
        $texto = $descr2;
2218
        $aFont = $this->formatPadrao;
2219
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2220
        
2221
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2222
        $texto = $descr3;
2223
        $aFont = $this->formatPadrao;
2224
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2225
        $auxX = $oldX;
2226
        $yIniDados += 3;
2227
        foreach ($this->infNF as $k => $d) {
2228
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2229
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2230
            $cnpj = $this->zFormatCNPJCPF($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...
2231
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2232
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2233
            if ($auxX > $w * 0.90) {
2234
                $yIniDados = $yIniDados + 3;
2235
                $auxX = $oldX;
2236
            }
2237
            $texto = $tp;
2238
            $aFont = array(
2239
                'font' => $this->fontePadrao,
2240
                'size' => 8,
2241
                'style' => '');
2242
            //$this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2243
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2244
            //$auxX += $w * 0.09;
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2245
            $auxX += $w * 0.07;
2246
            $texto = $cnpj;
2247
            $aFont = array(
2248
                'font' => $this->fontePadrao,
2249
                'size' => 8,
2250
                'style' => '');
2251
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2252
            $auxX += $w * 0.28;
2253
            $texto = $doc;
2254
            $aFont = array(
2255
                'font' => $this->fontePadrao,
2256
                'size' => 8,
2257
                'style' => '');
2258
            $this->pTextBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2259
            $auxX += $w * 0.15;
2260
        }
2261
        
2262
        foreach ($this->infNFe as $k => $d) {
2263
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2264
            $this->arrayNFe[] = $chaveNFe;
2265
        }
2266
        if (count($this->arrayNFe) >15) {
2267
            $this->flagDocOrigContinuacao = 1;
2268
            $totPag = '2';
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...
2269
        } else {
2270
            $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...
2271
        }
2272
        $totPag = count($this->arrayNFe) >15 ? '2' : '1';
2273
        
2274
        $r = $this->zCabecalho(1, 1, '1', $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...
2275
        $contador = 0;
2276
        while ($contador < 16) {
2277
            $tp = 'NF-e';
2278
            $chaveNFe = $this->arrayNFe[$contador];
2279
            $numNFe = substr($chaveNFe, 25, 9);
2280
            $serieNFe = substr($chaveNFe, 22, 3);
2281
            $doc = $serieNFe . '/' . $numNFe;
2282
            if ($auxX > $w * 0.90) {
2283
                $yIniDados = $yIniDados + 3.5;
2284
                $auxX = $oldX;
2285
            }
2286
            $texto = $tp;
2287
            $aFont = array(
2288
                'font' => $this->fontePadrao,
2289
                'size' => 7,
2290
                'style' => '');
2291
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2292
            $auxX += $w * 0.07;
2293
            $texto = $chaveNFe;
2294
            $aFont = array(
2295
                'font' => $this->fontePadrao,
2296
                'size' => 7,
2297
                'style' => '');
2298
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2299
            $auxX += $w * 0.28;
2300
            $texto = $doc;
2301
            $aFont = array(
2302
                'font' => $this->fontePadrao,
2303
                'size' => 7,
2304
                'style' => '');
2305
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2306
            $auxX += $w * 0.15;
2307
            $contador++;
2308
        }
2309
        
2310
        foreach ($this->infOutros as $k => $d) {
2311
            $temp = $this->infOutros->item($k);
2312
            $tpDoc = $this->pSimpleGetValue($temp, "tpDoc");
2313
            $descOutros = $this->pSimpleGetValue($temp, "descOutros");
2314
            $nDoc = $this->pSimpleGetValue($temp, "nDoc");
2315
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
2316
            $vDocFisc = $this->pSimpleGetValue($temp, "vDocFisc", "Valor: ");
2317
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
2318
            switch ($tpDoc) {
2319
                case "00":
2320
                    $tpDoc = "00 - Declaração";
2321
                    break;
2322
                case "10":
2323
                    $tpDoc = "10 - Dutoviário";
2324
                    break;
2325
                case "99":
2326
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2327
                    break;
2328
                default:
2329
                    break;
2330
            }
2331
            $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...
2332
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2333
            if ($auxX > $w * 0.90) {
2334
                $yIniDados = $yIniDados + 4;
2335
                $auxX = $oldX;
2336
            }
2337
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2338
            $auxX += $w * 0.09;
2339
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2340
            $auxX += $w * 0.28;
2341
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2342
            $auxX += $w * 0.14;
2343
        }
2344
    } //fim da função zDocOrig
2345
2346
    /**
2347
     * zDocOrigContinuacao
2348
     * Monta o campo com os documentos originarios.
2349
     *
2350
     * @param  number $x Posição horizontal canto esquerdo
2351
     * @param  number $y Posição vertical canto superior
2352
     * @return number Posição vertical final
2353
     */
2354
    protected function zDocOrigContinuacao($x = 0, $y = 0)
2355
    {
2356
        $this->pdf->AddPage($this->orientacao, $this->papel);
2357
        $r = $this->zCabecalho(1, 1, '2', '2');
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...
2358
        $oldX = $x;
2359
        $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...
2360 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2361
            $maxW = $this->wPrint;
2362
        } else {
2363
            $maxW = $this->wPrint - $this->wCanhoto;
2364
        }
2365
        $w = $maxW;
2366
        
2367
        //$h = 6; // de sub-titulo
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2368
        //$h = 6 + 3; // de altura do texto (primeira linha
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2369
        //$h = 9 + 3.5 ;// segunda linha
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2370
        //$h = 9 + 3.5+ 3.5 ;// segunda linha
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2371
        $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9;
2372
        if (count($this->arrayNFe)%2 !=0) {
2373
            $h = $h+3.5;
2374
        } // Caso tenha apenas 1 registro na ultima linha
2375
        
2376
        $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2377
        $aFont = $this->formatPadrao;
2378
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2379
        $descr1 = 'TIPO DOC';
2380
        $descr2 = 'CNPJ/CHAVE/OBS';
2381
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2382
        
2383
        $y += 3.4;
2384
        $this->pdf->Line($x, $y, $w + 1, $y);
2385
        $texto = $descr1;
2386
        $aFont = $this->formatPadrao;
2387
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2388
        $yIniDados = $y;
2389
        
2390
        $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2391
        $texto = $descr2;
2392
        $aFont = $this->formatPadrao;
2393
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2394
        
2395
        $x += $w * 0.28;
2396
        $texto = $descr3;
2397
        $aFont = $this->formatPadrao;
2398
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2399
        
2400
        $x += $w * 0.14;
2401 View Code Duplication
        if ($this->modal == '1') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2402
            if ($this->lota == 1) {
2403
                $this->pdf->Line($x, $y, $x, $y + 31.5);
2404
            } else {
2405
                $this->pdf->Line($x, $y, $x, $y + 49.5);
2406
            }
2407
        } elseif ($this->modal == '3') {
2408
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2409
        } else {
2410
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2411
        }
2412
        $texto = $descr1;
2413
        $aFont = $this->formatPadrao;
2414
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2415
                
2416
        $x += $w * 0.08;
2417
        $texto = $descr2;
2418
        $aFont = $this->formatPadrao;
2419
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2420
        
2421
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2422
        $texto = $descr3;
2423
        $aFont = $this->formatPadrao;
2424
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2425
        $auxX = $oldX;
2426
        $yIniDados += 3;
2427
        
2428
        $contador = 16;
0 ignored issues
show
Unused Code introduced by
$contador 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...
2429
        for ($contador = 16; $contador < count($this->arrayNFe); $contador++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
2430
            $tp = 'NF-e';
2431
            $chaveNFe = $this->arrayNFe[$contador];
2432
            $numNFe = substr($chaveNFe, 25, 9);
2433
            $serieNFe = substr($chaveNFe, 22, 3);
2434
            $doc = $serieNFe . '/' . $numNFe;
2435
            if ($auxX > $w * 0.90) {
2436
                $yIniDados = $yIniDados + 3.5;
2437
                $auxX = $oldX;
2438
            }
2439
            $texto = $tp;
2440
            $aFont = array(
2441
                'font' => $this->fontePadrao,
2442
                'size' => 7,
2443
                'style' => '');
2444
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2445
            $auxX += $w * 0.07;
2446
            $texto = $chaveNFe;
2447
            $aFont = array(
2448
                'font' => $this->fontePadrao,
2449
                'size' => 7,
2450
                'style' => '');
2451
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2452
            $auxX += $w * 0.28;
2453
            $texto = $doc;
2454
            $aFont = array(
2455
                'font' => $this->fontePadrao,
2456
                'size' => 7,
2457
                'style' => '');
2458
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2459
            $auxX += $w * 0.15;
2460
        }
2461
    } //fim da função zDocOrigContinuacao
2462
2463
    /**
2464
     * zDocCompl
2465
     * Monta o campo com os dados do remetente na DACTE.
2466
     *
2467
     * @param number $x Posição horizontal canto esquerdo
2468
     * @param number $y Posição vertical canto superior
2469
     * @return number Posição vertical final
2470
     */
2471
    protected function zDocCompl($x = 0, $y = 0)
2472
    {
2473
        $oldX = $x;
2474
        $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...
2475 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2476
            $maxW = $this->wPrint;
2477
        } else {
2478
            $maxW = $this->wPrint - $this->wCanhoto;
2479
        }
2480
        $w = $maxW;
2481
        $h = 80;
2482
        $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2483
        $aFont = $this->formatPadrao;
2484
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2485
        $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2486
        $descr2 = 'VALOR COMPLEMENTADO';
2487
        $y += 3.4;
2488
        $this->pdf->Line($x, $y, $w + 1, $y);
2489
        $texto = $descr1;
2490
        $aFont = $this->formatPadrao;
2491
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2492
        $yIniDados = $y;
2493
        $x += $w * 0.37;
2494
        $texto = $descr2;
2495
        $aFont = $this->formatPadrao;
2496
        $this->pTextBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2497
        $x += $w * 0.13;
2498
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2499
        $texto = $descr1;
2500
        $aFont = $this->formatPadrao;
2501
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2502
        $x += $w * 0.3;
2503
        $texto = $descr2;
2504
        $aFont = $this->formatPadrao;
2505
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2506
        $auxX = $oldX;
2507
        $yIniDados += 4;
2508
        if ($auxX > $w * 0.90) {
2509
            $yIniDados = $yIniDados + 4;
2510
            $auxX = $oldX;
2511
        }
2512
        $texto = $this->chaveCTeRef;
2513
        $aFont = array(
2514
            'font' => $this->fontePadrao,
2515
            'size' => 8,
2516
            'style' => '');
2517
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2518
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
2519
        $aFont = array(
2520
            'font' => $this->fontePadrao,
2521
            'size' => 8,
2522
            'style' => '');
2523
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2524
    } //fim da função zDocCompl
2525
2526
    /**
2527
     * zObs
2528
     * Monta o campo com os dados do remetente na DACTE.
2529
     *
2530
     * @param  number $x Posição horizontal canto esquerdo
2531
     * @param  number $y Posição vertical canto superior
2532
     * @return number Posição vertical final
2533
     */
2534
    protected function zObs($x = 0, $y = 0)
2535
    {
2536
        $oldX = $x;
2537
        $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...
2538 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2539
            $maxW = $this->wPrint;
2540
        } else {
2541
            $maxW = $this->wPrint - $this->wCanhoto;
2542
        }
2543
        $w = $maxW;
2544
        //$h = 18;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2545
        $h = 12;
2546
        $texto = 'OBSERVAÇÕES';
2547
        $aFont = $this->formatPadrao;
2548
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2549
        $y += 3.4;
2550
        $this->pdf->Line($x, $y, $w + 1, $y);
2551
        $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...
2552
        $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...
2553
        $texto = '';
2554
        foreach ($this->compl as $k => $d) {
2555
            $xObs = $this->pSimpleGetValue($this->compl->item($k), "xObs");
2556
            $texto .= "\r\n" . $xObs;
2557
        }
2558
        $texto .= $this->pSimpleGetValue($this->imp, "infAdFisco", "\r\n");
2559
        $texto .= $this->zLocalEntrega();
2560
        $aFont = array(
2561
            'font' => $this->fontePadrao,
2562
            'size' => 7.5,
2563
            'style' => '');
2564
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '', false);
2565
    } //fim da função obsDACTE
2566
2567
    /**
2568
     * zLocalEntrega
2569
     *
2570
     * @return string
2571
     */
2572
    protected function zLocalEntrega()
2573
    {
2574
        $locEntX = $this->dest->getElementsByTagName('locEnt');
2575
        if ($locEntX->length > 0) {
2576
            $locEnt = $locEntX->item(0);
2577
            $output = "Entrega: " . $output = $this->zFormatCNPJCPF($locEnt);
2578
            $output .= $this->pSimpleGetValue($locEnt, "CPF") . " ";
2579
            $output .= $this->pSimpleGetValue($locEnt, "xNome") . " ";
2580
            $output .= $this->pSimpleGetValue($locEnt, "xLgr") . " ";
2581
            $output .= $this->pSimpleGetValue($locEnt, "nro ") . " ";
2582
            $output .= $this->pSimpleGetValue($locEnt, "xCpl") . " ";
2583
            $output .= $this->pSimpleGetValue($locEnt, "xBairro") . " ";
2584
            $output .= $this->pSimpleGetValue($locEnt, "xMun") . " ";
2585
            $output .= $this->pSimpleGetValue($locEnt, "UF") . " ";
2586
            return $output;
2587
        }
2588
        return "";
2589
    } //fim zLocalEntrega
2590
2591
    /**
2592
     * zModalRod
2593
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2594
     *
2595
     * @param  number $x Posição horizontal canto esquerdo
2596
     * @param  number $y Posição vertical canto superior
2597
     * @return number Posição vertical final
2598
     */
2599
    protected function zModalRod($x = 0, $y = 0)
2600
    {
2601
        $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...
2602
        $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...
2603
        $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...
2604 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2605
            $maxW = $this->wPrint;
2606
        } else {
2607
            $maxW = $this->wPrint - $this->wCanhoto;
2608
        }
2609
        $w = $maxW;
2610 View Code Duplication
        if ($this->modal == '1') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2611
            $h = $this->lota == 1 ? 12.5 : 3.7;
2612
            $lotacao = 'Sim';
2613
        } else {
2614
            $h = 12.5;
2615
            $lotacao = 'Não';
2616
        }
2617
        $textolota = $this->lota == 1 ? 'LOTAÇÃO' : 'CARGA FRACIONADA';
2618
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO - ' . $textolota;
2619
        $aFont = $this->formatPadrao;
2620
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2621
        if ($this->lota == 1) {
2622
            $this->pdf->Line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2623
        }
2624
        $y += 3.4;
2625
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2626
        $texto = 'RNTRC DA EMPRESA';
2627
        $aFont = $this->formatPadrao;
2628
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2629
        $texto = $this->pSimpleGetValue($this->rodo, "RNTRC");
2630
        $aFont = $this->formatNegrito;
2631
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2632
        $x += $w * 0.23;
2633
        
2634
        //$this->pdf->Line($x, $y, $x, $y + 8.5);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2635
        $this->pdf->Line($x-20, $y, $x-20, $y + 8.5); // LINHA A FRENTE DA RNTRC DA EMPRESA
2636
        $texto = 'CIOT';
2637
        $aFont = $this->formatPadrao;
2638
        $this->pTextBox($x-20, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2639
        $texto = $this->pSimpleGetValue($this->rodo, "CIOT");
2640
        $aFont = $this->formatNegrito;
2641
        $this->pTextBox($x-20, $y + 3, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2642
        
2643
        //$this->pdf->Line($x, $y, $x, $y + 8.5);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2644
        $this->pdf->Line($x+10, $y, $x+10, $y + 8.5); // LINHA A FRENTE DO CIOT
2645
        $texto = 'LOTAÇÃO';
2646
        $aFont = $this->formatPadrao;
2647
        $this->pTextBox($x+10, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2648
        $texto = $lotacao;
2649
        $aFont = $this->formatNegrito;
2650
        $this->pTextBox($x+10, $y + 3, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2651
        
2652
        $x += $w * 0.13;
2653
        $this->pdf->Line($x, $y, $x, $y + 8.5);
2654
        $texto = 'DATA PREVISTA DE ENTREGA';
2655
        $aFont = $this->formatPadrao;
2656
        $this->pTextBox($x, $y, $w * 0.15, $h, $texto, $aFont, 'T', 'L', 0, '');
2657
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rodo, "dPrev"));
2658
        $aFont = $this->formatNegrito;
2659
        $this->pTextBox($x, $y + 3, $w * 0.15, $h, $texto, $aFont, 'T', 'L', 0, '');
2660
        $x += $w * 0.15;
2661
        $this->pdf->Line($x, $y, $x, $y + 8.5);
2662
        $h = 25;
2663
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE ' . "\r\n";
2664
        $texto .= ' À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2665
        $aFont = $this->formatPadrao;
2666
        $this->pTextBox($x, $y + 1, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2667
        if ($this->lota == 1) {
2668
            $y += 10;
2669
            $x = 1;
2670
            $texto = 'IDENTIFICAÇÃO DO CONJUNTO TRANSPORTADOR';
2671
            $aFont = $this->formatPadrao;
2672
            $this->pTextBox($x, $y, $w * 0.465, $h, $texto, $aFont, 'T', 'C', 0, '');
2673
            $this->pdf->Line($x, $y + 3.5, $w * 0.465, $y + 3.5);
2674
            $y += 3.5;
2675
            $texto = 'TIPO';
2676
            $aFont = $this->formatPadrao;
2677
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2678
            $yIniDados = $y;
2679
            if (count($this->veic) >= 0) {
2680
                foreach ($this->veic as $k => $d) {
2681
                    $yIniDados = $yIniDados + 3;
2682
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "tpVeic");
2683
                    switch ($texto) {
2684
                        case '0':
2685
                            $texto = 'Tração';
2686
                            break;
2687
                        case '1':
2688
                            $texto = 'Reboque';
2689
                            break;
2690
                        default:
2691
                            $texto = ' ';
2692
                    }
2693
                    $aFont = array(
2694
                        'font' => $this->fontePadrao,
2695
                        'size' => 6,
2696
                        'style' => 'B');
2697
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2698
                } //fim foreach
2699
            }
2700
            $x += $w * 0.10;
2701
            $texto = 'PLACA';
2702
            $aFont = $this->formatPadrao;
2703
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2704
            $this->pdf->Line($x, $y, $x, $y + 14);
2705
            $yIniDados = $y;
2706 View Code Duplication
            if (count($this->veic) >= 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2707
                foreach ($this->veic as $k => $d) {
2708
                    $yIniDados = $yIniDados + 3;
2709
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "placa");
2710
                    $aFont = array(
2711
                        'font' => $this->fontePadrao,
2712
                        'size' => 6,
2713
                        'style' => 'B');
2714
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2715
                }
2716
            }
2717
            $x += $w * 0.13;
2718
            $texto = 'UF';
2719
            $aFont = $this->formatPadrao;
2720
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2721
            $this->pdf->Line($x, $y, $x, $y + 23);
2722
            $yIniDados = $y;
2723 View Code Duplication
            if (count($this->veic) >= 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2724
                foreach ($this->veic as $k => $d) {
2725
                    $yIniDados = $yIniDados + 3;
2726
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "UF");
2727
                    $aFont = array(
2728
                        'font' => $this->fontePadrao,
2729
                        'size' => 6,
2730
                        'style' => 'B');
2731
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2732
                }
2733
            }
2734
            $x += $w * 0.03;
2735
            $texto = 'RNTRC';
2736
            $aFont = $this->formatPadrao;
2737
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2738
            $this->pdf->Line($x, $y, $x, $y + 14);
2739
            $yIniDados = $y;
2740 View Code Duplication
            if (count($this->veic) >= 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2741
                foreach ($this->veic as $k => $d) {
2742
                    $yIniDados = $yIniDados + 3;
2743
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "RNTRC");
2744
                    $aFont = array(
2745
                        'font' => $this->fontePadrao,
2746
                        'size' => 6,
2747
                        'style' => 'B');
2748
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2749
                }
2750
            }
2751
            $y += 14;
2752
            $x = 1;
2753
            $texto = 'NOME DO MOTORISTA';
2754
            $aFont = array(
2755
                'font' => $this->fontePadrao,
2756
                'size' => 5,
2757
                'style' => '');
2758
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2759
            $this->pdf->Line($x, $y, $w + 1, $y);
2760
            $texto = !empty($this->moto) ? $this->pSimpleGetValue($this->moto, "xNome") : '';
2761
            $aFont = array(
2762
                'font' => $this->fontePadrao,
2763
                'size' => 7,
2764
                'style' => 'B');
2765
            $this->pTextBox($x, $y + 3, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
2766
            $x += $w * 0.23;
2767
            $texto = 'CPF MOTORISTA';
2768
            $aFont = array(
2769
                'font' => $this->fontePadrao,
2770
                'size' => 5,
2771
                'style' => '');
2772
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2773
            //$texto = !empty($this->moto) ? $this->pSimpleGetValue($this->moto, "CPF") : '';  // CPF SEM MASCARA
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2774
            $texto = !empty($this->moto) ? $this->zFormatCNPJCPF($this->moto) : '';            // CPF COM MASCARA
2775
            $aFont = array(
2776
                'font' => $this->fontePadrao,
2777
                'size' => 7,
2778
                'style' => 'B');
2779
            $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2780
            $x += $w * 0.23;
2781
            $texto = 'IDENTIFICAÇÃO DOS LACRES EM TRANSITO';
2782
            $aFont = array(
2783
                'font' => $this->fontePadrao,
2784
                'size' => 5,
2785
                'style' => '');
2786
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2787
            $this->pdf->Line($x, $y, $x, $y - 18.7);
2788
            $this->pdf->Line($x, $y, $x, $y + 9);
2789
            $x = $w * 0.465;
2790
            $y -= 16;
2791
            $texto = 'INFORMAÇÕES REFERENTES AO VALE PEDÁGIO';
2792
            $aFont = $this->formatPadrao;
2793
            $this->pTextBox($x, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2794
            $this->pdf->Line($x, $y + 4, $w + 1, $y + 4);
2795
            $y += 4;
2796
            $texto = 'CNPJ FORNECEDOR';
2797
            $aFont = array(
2798
                'font' => $this->fontePadrao,
2799
                'size' => 5,
2800
                'style' => '');
2801
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2802
            $this->pdf->Line($x, $y + 4, $w + 1, $y + 4);
2803
            $y += 4;
2804
            $texto = 'NUMERO COMPROVANTE';
2805
            $aFont = array(
2806
                'font' => $this->fontePadrao,
2807
                'size' => 5,
2808
                'style' => '');
2809
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2810
            $this->pdf->Line($x, $y + 4, $w + 1, $y + 4);
2811
            $y += 4;
2812
            $texto = 'CNPJ RESPONSÁVEL';
2813
            $aFont = array(
2814
                'font' => $this->fontePadrao,
2815
                'size' => 5,
2816
                'style' => '');
2817
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2818
        }
2819
    } //fim da função zModalRod
2820
2821
    /**
2822
     * zModalAquaviario
2823
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2824
     *
2825
     * @param  number $x Posição horizontal canto esquerdo
2826
     * @param  number $y Posição vertical canto superior
2827
     * @return number Posição vertical final
2828
     */
2829
    protected function zModalAquaviario($x = 0, $y = 0)
2830
    {
2831
        $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...
2832
        $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...
2833 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2834
            $maxW = $this->wPrint;
2835
        } else {
2836
            $maxW = $this->wPrint - $this->wCanhoto;
2837
        }
2838
        $w = $maxW;
2839
        $h = 8.5;
2840
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2841
        $aFont = $this->formatPadrao;
2842
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2843
        $y += 3.4;
2844
        $this->pdf->Line($x, $y, $w + 1, $y);
2845
        $texto = 'PORTO DE EMBARQUE';
2846
        $aFont = $this->formatPadrao;
2847
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2848
        $texto = $this->pSimpleGetValue($this->aquav, "prtEmb");
2849
        $aFont = $this->formatNegrito;
2850
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2851
        $x += $w * 0.50;
2852
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2853
        $texto = 'PORTO DE DESTINO';
2854
        $aFont = $this->formatPadrao;
2855
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2856
        $texto = $this->pSimpleGetValue($this->aquav, "prtDest");
2857
        $aFont = $this->formatNegrito;
2858
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2859
        $y += 8;
2860
        $this->pdf->Line(208, $y, 1, $y);
2861
        $x = 1;
2862
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2863
        $aFont = $this->formatPadrao;
2864
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2865
        $texto = $this->pSimpleGetValue($this->aquav, "xNavio");
2866
        $aFont = $this->formatNegrito;
2867
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2868
        $x += $w * 0.50;
2869
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2870
        $texto = 'VR DA B. DE CALC. AFRMM';
2871
        $aFont = $this->formatPadrao;
2872
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2873
        $texto = $this->pSimpleGetValue($this->aquav, "vPrest");
2874
        $aFont = $this->formatNegrito;
2875
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2876
        $x += $w * 0.17;
2877
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2878
        $texto = 'VALOR DO AFRMM';
2879
        $aFont = $this->formatPadrao;
2880
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2881
        $texto = $this->pSimpleGetValue($this->aquav, "vAFRMM");
2882
        $aFont = $this->formatNegrito;
2883
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2884
        $x += $w * 0.12;
2885
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2886
        $texto = 'TIPO DE NAVEGAÇÃO';
2887
        $aFont = $this->formatPadrao;
2888
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2889
        $texto = $this->pSimpleGetValue($this->aquav, "tpNav");
2890
        switch ($texto) {
2891
            case '0':
2892
                $texto = 'INTERIOR';
2893
                break;
2894
            case '1':
2895
                $texto = 'CABOTAGEM';
2896
                break;
2897
        }
2898
        $aFont = $this->formatNegrito;
2899
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2900
        $x += $w * 0.14;
2901
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2902
        $texto = 'DIREÇÃO';
2903
        $aFont = $this->formatPadrao;
2904
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2905
        $texto = $this->pSimpleGetValue($this->aquav, "direc");
2906
        switch ($texto) {
2907
            case 'N':
2908
                $texto = 'NORTE';
2909
                break;
2910
            case 'L':
2911
                $texto = 'LESTE';
2912
                break;
2913
            case 'S':
2914
                $texto = 'SUL';
2915
                break;
2916
            case 'O':
2917
                $texto = 'OESTE';
2918
                break;
2919
        }
2920
        $aFont = $this->formatNegrito;
2921
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2922
        $y += 8;
2923
        $this->pdf->Line(208, $y, 1, $y);
2924
        $x = 1;
2925
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2926
        $aFont = $this->formatPadrao;
2927
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2928
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2929
            $texto = $this->infNF
2930
                ->item(0)
2931
                ->getElementsByTagName('infUnidCarga')
2932
                ->item(0)
2933
                ->getElementsByTagName('idUnidCarga')
2934
                ->item(0)->nodeValue;
2935
        } elseif ($this->infNFe->item(0) !== null
2936
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2937
        ) {
2938
            $texto = $this->infNFe
2939
                ->item(0)
2940
                ->getElementsByTagName('infUnidCarga')
2941
                ->item(0)
2942
                ->getElementsByTagName('idUnidCarga')
2943
                ->item(0)
2944
                ->nodeValue;
2945
        } elseif ($this->infOutros->item(0) !== null
2946
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2947
        ) {
2948
            $texto = $this->infOutros
2949
                ->item(0)
2950
                ->getElementsByTagName('infUnidCarga')
2951
                ->item(0)
2952
                ->getElementsByTagName('idUnidCarga')
2953
                ->item(0)
2954
                ->nodeValue;
2955
        } else {
2956
            $texto = '';
2957
        }
2958
        $aFont = $this->formatNegrito;
2959
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2960
        $x += $w * 0.50;
2961
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2962
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2963
        $aFont = $this->formatPadrao;
2964
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2965
        $texto = '';
2966
        if ($this->pSimpleGetValue($this->aquav, "balsa") !== '') {
2967
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2968
                if ($k == 0) {
2969
                    $texto = $this->aquav
2970
                        ->getElementsByTagName('balsa')
2971
                        ->item($k)
2972
                        ->getElementsByTagName('xBalsa')
2973
                        ->item(0)
2974
                        ->nodeValue;
2975
                } else {
2976
                    $texto = $texto
2977
                        . ' / '
2978
                        . $this->aquav
2979
                            ->getElementsByTagName('balsa')
2980
                            ->item($k)
2981
                            ->getElementsByTagName('xBalsa')
2982
                            ->item(0)
2983
                            ->nodeValue;
2984
                }
2985
            }
2986
        }
2987
        $aFont = $this->formatNegrito;
2988
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2989
    } //fim da função zModalRod
2990
2991
    /**
2992
     * zModalFerr
2993
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2994
     *
2995
     * @param  number $x Posição horizontal canto esquerdo
2996
     * @param  number $y Posição vertical canto superior
2997
     * @return number Posição vertical final
2998
     */
2999
    protected function zModalFerr($x = 0, $y = 0)
3000
    {
3001
        $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...
3002
        $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...
3003 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3004
            $maxW = $this->wPrint;
3005
        } else {
3006
            $maxW = $this->wPrint - $this->wCanhoto;
3007
        }
3008
        $w = $maxW;
3009
        $h = 19.6;
3010
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
3011
        $aFont = $this->formatPadrao;
3012
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3013
        $y += 3.4;
3014
        $this->pdf->Line($x, $y, $w + 1, $y);
3015
        $texto = 'DCL';
3016
        $aFont = array(
3017
            'font' => $this->fontePadrao,
3018
            'size' => 7,
3019
            'style' => 'B');
3020
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
3021
        $this->pdf->Line($x + 49.6, $y, $x + 49.6, $y + 3.5);
3022
        $texto = 'VAGÕES';
3023
        $aFont = array(
3024
            'font' => $this->fontePadrao,
3025
            'size' => 7,
3026
            'style' => 'B');
3027
        $this->pTextBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
3028
        $y += 3.4;
3029
        $this->pdf->Line($x, $y, $w + 1, $y);
3030
        // DCL
3031
        $texto = 'ID TREM';
3032
        $aFont = array(
3033
            'font' => $this->fontePadrao,
3034
            'size' => 6,
3035
            'style' => '');
3036
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3037
        $texto = $this->pSimpleGetValue($this->ferrov, "idTrem");
3038
        $aFont = array(
3039
            'font' => $this->fontePadrao,
3040
            'size' => 6,
3041
            'style' => 'B');
3042
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3043
        $x += $w * 0.06;
3044
        $y1 = $y + 12.5;
3045
        $this->pdf->Line($x, $y, $x, $y1);
3046
        $texto = 'NUM';
3047
        $aFont = array(
3048
            'font' => $this->fontePadrao,
3049
            'size' => 6,
3050
            'style' => '');
3051
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3052
        $texto = $this->pSimpleGetValue($this->rem, "nDoc");
3053
        $aFont = array(
3054
            'font' => $this->fontePadrao,
3055
            'size' => 6,
3056
            'style' => 'B');
3057
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3058
        $x += $w * 0.06;
3059
        $this->pdf->Line($x, $y, $x, $y1);
3060
        $texto = 'SÉRIE';
3061
        $aFont = array(
3062
            'font' => $this->fontePadrao,
3063
            'size' => 6,
3064
            'style' => '');
3065
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3066
        $texto = $this->pSimpleGetValue($this->rem, "serie");
3067
        $aFont = array(
3068
            'font' => $this->fontePadrao,
3069
            'size' => 6,
3070
            'style' => 'B');
3071
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3072
        $x += $w * 0.06;
3073
        $this->pdf->Line($x, $y, $x, $y1);
3074
        $texto = 'EMISSÃO';
3075
        $aFont = array(
3076
            'font' => $this->fontePadrao,
3077
            'size' => 6,
3078
            'style' => '');
3079
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3080
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rem, "dEmi"));
3081
        $aFont = array(
3082
            'font' => $this->fontePadrao,
3083
            'size' => 6,
3084
            'style' => 'B');
3085
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3086
        // VAGOES
3087
        $x += $w * 0.06;
3088
        $this->pdf->Line($x, $y, $x, $y1);
3089
        $texto = 'NUM';
3090
        $aFont = array(
3091
            'font' => $this->fontePadrao,
3092
            'size' => 6,
3093
            'style' => '');
3094
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3095
        $texto = $this->pSimpleGetValue($this->ferrov, "nVag");
3096
        $aFont = array(
3097
            'font' => $this->fontePadrao,
3098
            'size' => 6,
3099
            'style' => 'B');
3100
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3101
        $x += $w * 0.06;
3102
        $this->pdf->Line($x, $y, $x, $y1);
3103
        $texto = 'TIPO';
3104
        $aFont = array(
3105
            'font' => $this->fontePadrao,
3106
            'size' => 6,
3107
            'style' => '');
3108
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3109
        $texto = $this->pSimpleGetValue($this->ferrov, "tpVag");
3110
        $aFont = array(
3111
            'font' => $this->fontePadrao,
3112
            'size' => 6,
3113
            'style' => 'B');
3114
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3115
        $x += $w * 0.06;
3116
        $this->pdf->Line($x, $y, $x, $y1);
3117
        $texto = 'CAPACIDADE';
3118
        $aFont = array(
3119
            'font' => $this->fontePadrao,
3120
            'size' => 6,
3121
            'style' => '');
3122
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3123
        $texto = $this->pSimpleGetValue($this->ferrov, "cap");
3124
        $aFont = array(
3125
            'font' => $this->fontePadrao,
3126
            'size' => 6,
3127
            'style' => 'B');
3128
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3129
        $x += $w * 0.08;
3130
        $this->pdf->Line($x, $y, $x, $y1);
3131
        $texto = 'PESO REAL/TON';
3132
        $aFont = array(
3133
            'font' => $this->fontePadrao,
3134
            'size' => 6,
3135
            'style' => '');
3136
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3137
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoR");
3138
        $aFont = array(
3139
            'font' => $this->fontePadrao,
3140
            'size' => 6,
3141
            'style' => 'B');
3142
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3143
        $x += $w * 0.09;
3144
        $this->pdf->Line($x, $y, $x, $y1);
3145
        $texto = 'PESO BRUTO/TON';
3146
        $aFont = array(
3147
            'font' => $this->fontePadrao,
3148
            'size' => 6,
3149
            'style' => '');
3150
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3151
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoBC");
3152
        $aFont = array(
3153
            'font' => $this->fontePadrao,
3154
            'size' => 6,
3155
            'style' => 'B');
3156
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3157
        $x += $w * 0.1;
3158
        $this->pdf->Line($x, $y, $x, $y1);
3159
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3160
        $aFont = array(
3161
            'font' => $this->fontePadrao,
3162
            'size' => 6,
3163
            'style' => '');
3164
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3165
        $texto = $this->pSimpleGetValue($this->ferrov, "nCont");
3166
        $aFont = array(
3167
            'font' => $this->fontePadrao,
3168
            'size' => 6,
3169
            'style' => 'B');
3170
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3171
        // FLUXO
3172
        $x = 1;
3173
        $y += 12.9;
3174
        $h1 = $h * 0.5 + 0.27;
3175
        $wa = round($w * 0.103) + 0.5;
3176
        $texto = 'FLUXO FERROVIARIO';
3177
        $aFont = $this->formatPadrao;
3178
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3179
        $texto = $this->pSimpleGetValue($this->ferrov, "fluxo");
3180
        $aFont = array(
3181
            'font' => $this->fontePadrao,
3182
            'size' => 7,
3183
            'style' => 'B');
3184
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3185
        $y += 10;
3186
        $texto = 'TIPO DE TRÁFEGO';
3187
        $aFont = $this->formatPadrao;
3188
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3189
        $texto = $this->zConvertUnidTrafego($this->pSimpleGetValue($this->ferrov, "tpTraf"));
3190
        $aFont = array(
3191
            'font' => $this->fontePadrao,
3192
            'size' => 7,
3193
            'style' => 'B');
3194
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3195
        // Novo Box Relativo a Modal Ferroviário
3196
        $x = 22.5;
3197
        $y += -10.2;
3198
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3199
        $aFont = $this->formatPadrao;
3200
        $this->pTextBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3201
        $y += 3.4;
3202
        $this->pdf->Line($x, $y, $w + 1, $y);
3203
        $w = $w * 0.2;
3204
        $h = $h * 1.04;
3205
        $texto = 'CÓDIGO INTERNO';
3206
        $aFont = array(
3207
            'font' => $this->fontePadrao,
3208
            'size' => 6,
3209
            'style' => '');
3210
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3211
        $texto = $this->pSimpleGetValue($this->ferrov, "cInt");
3212
        $aFont = array(
3213
            'font' => $this->fontePadrao,
3214
            'size' => 6,
3215
            'style' => 'B');
3216
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3217
        $texto = 'CNPJ';
3218
        $aFont = array(
3219
            'font' => $this->fontePadrao,
3220
            'size' => 6,
3221
            'style' => '');
3222
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3223
        $texto = $this->pSimpleGetValue($this->ferrov, "CNPJ");
3224
        $aFont = array(
3225
            'font' => $this->fontePadrao,
3226
            'size' => 6,
3227
            'style' => 'B');
3228
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3229
        $x += 50;
3230
        $texto = 'NOME';
3231
        $aFont = array(
3232
            'font' => $this->fontePadrao,
3233
            'size' => 6,
3234
            'style' => '');
3235
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3236
        $texto = $this->pSimpleGetValue($this->ferrov, "xNome");
3237
        $aFont = array(
3238
            'font' => $this->fontePadrao,
3239
            'size' => 6,
3240
            'style' => 'B');
3241
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3242
        $texto = 'INSCRICAO ESTADUAL';
3243
        $aFont = array(
3244
            'font' => $this->fontePadrao,
3245
            'size' => 6,
3246
            'style' => '');
3247
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3248
        $texto = $this->pSimpleGetValue($this->ferrov, "IE");
3249
        $aFont = array(
3250
            'font' => $this->fontePadrao,
3251
            'size' => 6,
3252
            'style' => 'B');
3253
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3254
        $x += 50;
3255
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3256
        $aFont = array(
3257
            'font' => $this->fontePadrao,
3258
            'size' => 6,
3259
            'style' => '');
3260
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3261
        $texto = '';
3262
        $aFont = array(
3263
            'font' => $this->fontePadrao,
3264
            'size' => 6,
3265
            'style' => 'B');
3266
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3267
    } //fim da função zModalFerr
3268
3269
    /**
3270
     * zCanhoto
3271
     * Monta o campo com os dados do remetente na DACTE.
3272
     *
3273
     * @param  number $x Posição horizontal canto esquerdo
3274
     * @param  number $y Posição vertical canto superior
3275
     * @return number Posição vertical final
3276
     */
3277
    protected function zCanhoto($x = 0, $y = 0)
3278
    {
3279
        $this->zhDashedLine($x, $y+2, $this->wPrint, 0.1, 80);
3280
        $y = $y + 2;
3281
        $oldX = $x;
3282
        $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...
3283 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3284
            $maxW = $this->wPrint;
3285
        } else {
3286
            $maxW = $this->wPrint - $this->wCanhoto;
3287
        }
3288
        $w = $maxW - 1;
3289
        $h = 20;
3290
        $y = $y + 1;
3291
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3292
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3293
        $aFont = $this->formatPadrao;
3294
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3295
        $y += 3.4;
3296
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3297
        
3298
        $texto = 'NOME';
3299
        $aFont = array(
3300
            'font' => $this->fontePadrao,
3301
            'size' => 6,
3302
            'style' => '');
3303
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3304
        $x += $w * 0.25;
3305
        
3306
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3307
        
3308
        $texto = 'ASSINATURA / CARIMBO';
3309
        $aFont = array(
3310
            'font' => $this->fontePadrao,
3311
            'size' => 6,
3312
            'style' => '');
3313
        $this->pTextBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3314
        $x += $w * 0.25;
3315
        
3316
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3317
        
3318
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
3319
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3320
        $aFont = array(
3321
            'font' => $this->fontePadrao,
3322
            'size' => 6,
3323
            'style' => '');
3324
        $this->pTextBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3325
        $x = $oldX;
3326
        $y = $y + 5;
3327
        
3328
        $this->pdf->Line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3329
        
3330
        $texto = 'RG';
3331
        $aFont = array(
3332
            'font' => $this->fontePadrao,
3333
            'size' => 6,
3334
            'style' => '');
3335
        $this->pTextBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3336
        $x += $w * 0.85;
3337
        
3338
        $this->pdf->Line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3339
        
3340
        $texto = "CT-E";
3341
        $aFont = $this->formatNegrito;
3342
        $this->pTextBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3343
        $texto = "\r\n Nº. DOCUMENTO  " . $this->pSimpleGetValue($this->ide, "nCT") . " \n";
3344
        $texto .= "\r\n SÉRIE  " . $this->pSimpleGetValue($this->ide, "serie");
3345
        $aFont = array(
3346
            'font' => $this->fontePadrao,
3347
            'size' => 6,
3348
            'style' => '');
3349
        $this->pTextBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3350
        $x = $oldX;
0 ignored issues
show
Unused Code introduced by
$x 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...
3351
        //$this->zhDashedLine($x, $y + 7.5, $this->wPrint, 0.1, 80);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
3352
    } //fim da função canhotoDACTE
3353
3354
    /**
3355
     * zDadosAdic
3356
     * Coloca o grupo de dados adicionais da DACTE.
3357
     *
3358
     * @param  number $x Posição horizontal canto esquerdo
3359
     * @param  number $y Posição vertical canto superior
3360
     * @param  number $h altura do campo
3361
     * @return number Posição vertical final
3362
     */
3363
    protected function zDadosAdic($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...
3364
    {
3365
        $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...
3366
        //###########################################################################
3367
        //DADOS ADICIONAIS DACTE
3368
        if ($this->orientacao == 'P') {
3369
            $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...
3370
        } else {
3371
            $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...
3372
        }
3373
        //INFORMAÇÕES COMPLEMENTARES
3374
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3375
        $y += 3;
3376
        $w = $this->wAdic;
3377
        $h = 8; //mudar
3378
        $aFont = array(
3379
            'font' => $this->fontePadrao,
3380
            'size' => 6,
3381
            'style' => '');
3382
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3383
        //$this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
3384
        $this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3385
        //o texto com os dados adicionais foi obtido na função xxxxxx
3386
        //e carregado em uma propriedade privada da classe
3387
        //$this->wAdic com a largura do campo
3388
        //$this->textoAdic com o texto completo do campo
3389
        $y += 1;
3390
        $aFont = $this->formatPadrao;
3391
        $this->pTextBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3392
        //RESERVADO AO FISCO
3393
        $texto = "RESERVADO AO FISCO";
3394
        $x += $w;
3395
        $y -= 1;
3396 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3397
            $w = $this->wPrint - $w;
3398
        } else {
3399
            $w = $this->wPrint - $w - $this->wCanhoto;
3400
        }
3401
        $aFont = array(
3402
            'font' => $this->fontePadrao,
3403
            'size' => 6,
3404
            'style' => '');
3405
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3406
        //inserir texto informando caso de contingência
3407
        //1 – Normal – emissão normal;
3408
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3409
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3410
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3411
        //Emissão em Contingência – DPEC;
3412
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3413
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3414
        $xJust = $this->pSimpleGetValue($this->ide, 'xJust', 'Justificativa: ');
3415
        $dhCont = $this->pSimpleGetValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3416
        $texto = '';
3417
        switch ($this->tpEmis) {
3418
            case 2:
3419
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3420
                break;
3421
            case 3:
3422
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3423
                break;
3424
            case 4:
3425
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3426
                break;
3427
            case 5:
3428
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3429
                break;
3430
        }
3431
        $y += 2;
3432
        $aFont = $this->formatPadrao;
3433
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3434
        return $y + $h;
3435
    } //fim zDadosAdic
3436
3437
    /**
3438
     * zhDashedLine
3439
     * Desenha uma linha horizontal tracejada com o FPDF
3440
     *
3441
     * @param  number $x Posição horizontal inicial, em mm
3442
     * @param  number $y Posição vertical inicial, em mm
3443
     * @param  number $w Comprimento da linha, em mm
3444
     * @param  number $h Espessura da linha, em mm
3445
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3446
     * @return none
3447
     */
3448
    protected function zhDashedLine($x, $y, $w, $h, $n)
3449
    {
3450
        $this->pdf->SetLineWidth($h);
3451
        $wDash = ($w / $n) / 2; // comprimento dos traços
3452 View Code Duplication
        for ($i = $x; $i <= $x + $w; $i += $wDash + $wDash) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3453
            for ($j = $i; $j <= ($i + $wDash); $j++) {
3454
                if ($j <= ($x + $w - 1)) {
3455
                    $this->pdf->Line($j, $y, $j + 1, $y);
3456
                }
3457
            }
3458
        }
3459
    } //fim função hDashedLine
3460
3461
    /**
3462
     * zhDashedVerticalLine
3463
     * Desenha uma linha vertical tracejada com o FPDF
3464
     *
3465
     * @param  number $x Posição horizontal inicial, em mm
3466
     * @param  number $y Posição vertical inicial, em mm
3467
     * @param  number $w Comprimento da linha, em mm
3468
     * @param  number $yfinal Espessura da linha, em mm
3469
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3470
     * @return none
3471
     */
3472
    protected function zhDashedVerticalLine($x, $y, $w, $yfinal, $n)
3473
    {
3474
        $this->pdf->SetLineWidth($w);
3475
        /* Organizando valores */
3476
        if ($y > $yfinal) {
3477
            $aux = $yfinal;
3478
            $yfinal = $y;
3479
            $y = $aux;
3480
        }
3481
        while ($y < $yfinal && $n > 0) {
3482
            $this->pdf->Line($x, $y, $x, $y + 1);
3483
            $y += 3;
3484
            $n--;
3485
        }
3486
    } //fim função hDashedVerticalLine
3487
3488
    /**
3489
     * zFormatCNPJCPF
3490
     * Formata campo CnpjCpf contida na CTe
3491
     *
3492
     * @param  string $field campo cnpjCpf da CT-e
3493
     * @return string
3494
     */
3495
    protected function zFormatCNPJCPF($field)
3496
    {
3497
        if (!isset($field)) {
3498
            return '';
3499
        }
3500
        $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...
3501
            $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...
3502
        if ($cnpj != "" && $cnpj != "00000000000000") {
3503
            $cnpj = $this->pFormat($cnpj, '###.###.###/####-##');
3504
        } else {
3505
            $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...
3506
                $this->pFormat($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...
3507
        }
3508
        return $cnpj;
3509
    } //fim formatCNPJCPF
3510
3511
    /**
3512
     * zFormatFone
3513
     * Formata campo fone contida na CTe
3514
     *
3515
     * @param  string $field campo fone da CT-e
3516
     * @return string
3517
     */
3518
    protected function zFormatFone($field)
3519
    {
3520
        $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...
3521
            $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...
3522
        $foneLen = strlen($fone);
3523 View Code Duplication
        if ($foneLen > 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3524
            $fone2 = substr($fone, 0, $foneLen - 4);
3525
            $fone1 = substr($fone, 0, $foneLen - 8);
3526
            $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3527
        } else {
3528
            $fone = '';
3529
        }
3530
        return $fone;
3531
    } //fim formatFone
3532
3533
    /**
3534
     * zUnidade
3535
     * Converte a imformação de peso contida na CTe
3536
     *
3537
     * @param  string $c unidade de trafego extraida da CTe
3538
     * @return string
3539
     */
3540
    protected function zUnidade($c = '')
3541
    {
3542
        switch ($c) {
3543
            case '00':
3544
                $r = 'M3';
3545
                break;
3546
            case '01':
3547
                $r = 'KG';
3548
                break;
3549
            case '02':
3550
                $r = 'TON';
3551
                break;
3552
            case '03':
3553
                $r = 'UN';
3554
                break;
3555
            case '04':
3556
                $r = 'LT';
3557
                break;
3558
            case '05':
3559
                $r = 'MMBTU';
3560
                break;
3561
            default:
3562
                $r = '';
3563
        }
3564
        return $r;
3565
    } //fim unidade
3566
3567
    /**
3568
     * zConvertUnidTrafego
3569
     * Converte a imformação de peso contida na CTe
3570
     *
3571
     * @param  string $U Informação de trafego extraida da CTe
3572
     * @return string
3573
     */
3574
    protected function zConvertUnidTrafego($U = '')
3575
    {
3576
        if ($U) {
3577
            switch ($U) {
3578
                case '0':
3579
                    $stringU = 'Próprio';
3580
                    break;
3581
                case '1':
3582
                    $stringU = 'Mútuo';
3583
                    break;
3584
                case '2':
3585
                    $stringU = 'Rodoferroviário';
3586
                    break;
3587
                case '3':
3588
                    $stringU = 'Rodoviário';
3589
                    break;
3590
            }
3591
            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...
3592
        }
3593
    } //fim da função zConvertUnidTrafego
3594
3595
    /**
3596
     * zMultiUniPeso
3597
     * Fornece a imformação multiplicação de peso contida na CTe
3598
     *
3599
     * @param  interger $U Informação de peso extraida da CTe
3600
     * @return interger
3601
     */
3602
    protected function zMultiUniPeso($U = '')
3603
    {
3604
        if ($U === "01") {
3605
            // tonelada
3606
            //return 1000;
3607
            return 1;
3608
        }
3609
        return 1; // M3, KG, Unidade, litros, mmbtu
3610
    } //fim da função zMultiUniPeso
3611
}
3612