Completed
Pull Request — master (#87)
by
unknown
10:38
created

Make::zTestaChaveXML()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 35

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 35
rs 9.36
c 0
b 0
f 0
ccs 0
cts 0
cp 0
crap 6
1
<?php
2
3
namespace NFePHP\MDFe;
4
5
/**
6
 * Classe a construção do xml do Manifesto Eletrônico de Documentos Fiscais (MDF-e)
7
 * NOTA: Esta classe foi construida conforme estabelecido no
8
 * Manual de Orientação do Contribuinte
9
 * Padrões Técnicos de Comunicação do Manifesto Eletrônico de Documentos Fiscais
10
 * versão 3.00a
11
 *
12
 * @category  Library
13
 * @package   nfephp-org/sped-mdfe
14
 * @name      Make.php
15
 * @copyright 2009-2019 NFePHP
16
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
17
 * @link      http://github.com/nfephp-org/sped-mdfe for the canonical source repository
18
 * @author    Roberto L. Machado <linux.rlm at gmail dot com>
19
 */
20
21
use NFePHP\Common\Keys;
22
use NFePHP\Common\DOMImproved as Dom;
23
use NFePHP\Common\Strings;
24
use stdClass;
25
use RuntimeException;
26
use InvalidArgumentException;
27
use DOMElement;
28
use DateTime;
29
30
class Make
31
{
32
    /**
33
     * @var array
34
     */
35
    public $errors = [];
36
    /**
37
     * versao
38
     * numero da versão do xml da MDFe
39
     *
40
     * @var string
41
     */
42
    public $versao = '3.00';
43
    /**
44
     * mod
45
     * modelo da MDFe 58
46
     *
47
     * @var integer
48
     */
49
    public $mod = '58';
50
    /**
51
     * chave da MDFe
52
     *
53
     * @var string
54
     */
55
    public $chMDFe = '';
56
57
    //propriedades privadas utilizadas internamente pela classe
58
    /**
59
     * @type string|\DOMNode
60
     */
61
    private $MDFe = '';
62
    /**
63
     * @type string|\DOMNode
64
     */
65
    private $infMDFe = '';
66
    /**
67
     * @type string|\DOMNode
68
     */
69
    private $ide = '';
70
    /**
71
     * @type string|\DOMNode
72
     */
73
    private $emit = '';
74
    /**
75
     * @type string|\DOMNode
76
     */
77
    private $enderEmit = '';
78
    /**
79
     * @type string|\DOMNode
80
     */
81
    private $infModal = '';
82
    /**
83
     * @type string|\DOMNode
84
     */
85
    private $tot = '';
86
    /**
87
     * @type string|\DOMNode
88
     */
89
    private $seg = '';
90
    /**
91
     * @type string|\DOMNode
92
     */
93
    private $lacres = [];
94
    /**
95
     * @type string|\DOMNode
96
     */
97
    private $autXML = [];
98
    /**
99
     * @type string|\DOMNode
100
     */
101
    private $infAdic = '';
102
    /**
103
     * @type string|\DOMNode
104
     */
105
    private $rodo = '';
106
    /**
107
     * @type string|\DOMNode
108
     */
109
    private $infDoc = '';
110
    /**
111
     * @type string|\DOMNode
112
     */
113
    private $infUnidTransp = '';
114
    /**
115
     * @type string|\DOMNode
116
     */
117
    private $veicTracao = '';
118
    /**
119
     * @type string|\DOMNode
120
     */
121
    private $aereo = '';
122
    /**
123
     * @type string|\DOMNode
124
     */
125
    private $trem = '';
126
    /**
127
     * @type string|\DOMNode
128
     */
129
    private $aqua = '';
130
131
    /**
132
     * @var boolean
133
     */
134
    protected $replaceAccentedChars = false;
135
136
    /**
137
     * Função construtora cria um objeto DOMDocument
138
     * que será carregado com o documento fiscal
139
     */
140
    public function __construct()
141
    {
142
        $this->dom = new Dom('1.0', 'UTF-8');
0 ignored issues
show
Bug introduced by
The property dom does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
143
        $this->dom->preserveWhiteSpace = false;
144
        $this->dom->formatOutput = false;
145
    }
146
147
    public function getXML()
148
    {
149
        if (empty($this->xml)) {
0 ignored issues
show
Bug introduced by
The property xml 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...
150
            $this->montaMDFe();
151
        }
152
        return $this->xml;
153
    }
154
155
    /**
156
     * Retorns the key number of NFe (44 digits)
157
     * @return string
158
     */
159
    public function getChave()
160
    {
161
        return $this->chMDFe;
162
    }
163
164
    /**
165
     * Returns the model of NFe 55 or 65
166
     * @return int
167
     */
168
    public function getModelo()
169
    {
170
        return $this->mod;
171
    }
172
173
    /**
174
     * Call method of xml assembly. For compatibility only.
175
     * @return boolean
176
     */
177
    public function montaMDFe()
178
    {
179
        return $this->monta();
180
    }
181
182
    /**
183
     * MDFe xml mount method
184
     * this function returns TRUE on success or FALSE on error
185
     * The xml of the MDFe must be retrieved by the getXML() function or
186
     * directly by the public property $xml
187
     * @return boolean
188
     */
189
    public function monta()
190
    {
191
        $this->errors = $this->dom->errors;
192
        if (count($this->errors) > 0) {
193
            return false;
194
        }
195
        //cria a tag raiz da MDFe
196
        $this->buildMDFe();
197
        $this->buildInfModal();
198
        
199
        $this->infMDFe = $this->dom->createElement("infMDFe");
200
201
        $this->dom->appChild($this->infMDFe, $this->ide, 'Falta tag "ide"');
202
        $this->dom->appChild($this->emit, $this->enderEmit, 'Falta tag "enderEmit"');
203
        $this->dom->appChild($this->infMDFe, $this->emit, 'Falta tag "emit"');
204
        if (! empty($this->rodo)) {
205
            $this->dom->appChild($this->infModal, $this->rodo, 'Falta tag "infModal"');
206
        }
207
        $this->dom->appChild($this->infMDFe, $this->infModal, 'Falta tag "infModal"');
208
        $this->dom->appChild($this->infMDFe, $this->infDoc, 'Falta tag "infDoc"');
209
        if (!empty($this->seg)){
210
            $this->dom->appChild($this->infMDFe, $this->seg, 'Falta tag "seg"');
211
        }
212
        $this->dom->appChild($this->infMDFe, $this->tot, 'Falta tag "tot"');
213
        foreach ($this->lacres as $lacres) {
0 ignored issues
show
Bug introduced by
The expression $this->lacres of type string|object<DOMNode> is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
214
            $this->dom->appChild($this->infMDFe, $lacres, 'Falta tag "lacres"');
215
        }
216
        foreach ($this->autXML as $autXML) {
0 ignored issues
show
Bug introduced by
The expression $this->autXML of type string|object<DOMNode> is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
217
            $this->dom->appChild($this->infMDFe, $autXML, 'Falta tag "autXML"');
218
        }
219
        if (!empty($this->infAdic)){
220
            $this->dom->appChild($this->infMDFe, $this->infAdic, 'Falta tag "infAdic"');
221
        }
222
        
223
        $this->dom->appChild($this->MDFe, $this->infMDFe, 'Falta tag "infMDFe"');
224
        
225
        $this->dom->appendChild($this->MDFe);
226
227
        // testa da chave
228
        $this->checkMDFKey($this->dom);
229
        $this->xml = $this->dom->saveXML();
230
        
231
        return true;
232
    }
233
234
    /**
235
     * Informações de identificação da MDFe
236
     * tag MDFe/infMDFe/ide
237
     * @param  stdClass $std
238
     * @return DOMElement
239
     */
240
    public function tagide(stdClass $std)
241
    {
242
243
        $possible = [
244
            'cUF',
245
            'tpAmb',
246
            'tpEmit',
247
            'mod',
248
            'serie',
249
            'nMDF',
250
            'cMDF',
251
            'cDV',
252
            'modal',
253
            'dhEmi',
254
            'tpEmis',
255
            'procEmi',
256
            'verProc',
257
            'ufIni',
258
            'ufFim'
259
        ];
260
261
        $std = $this->equilizeParameters($std, $possible);
262
        
263
        $this->tpAmb = $std->tpAmb;
0 ignored issues
show
Bug introduced by
The property tpAmb 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...
264
        $identificador = '[4] <ide> - ';
265
        $ide = $this->dom->createElement("ide");
266
        $this->dom->addChild(
267
            $ide,
268
            "cUF",
269
            $std->cUF,
270
            true,
271
            $identificador . "Código da UF do emitente do Documento Fiscal"
272
        );
273
        $this->dom->addChild(
274
            $ide,
275
            "tpAmb",
276
            $std->tpAmb,
277
            true,
278
            $identificador . "Identificação do Ambiente"
279
        );
280
        $this->dom->addChild(
281
            $ide,
282
            "tpEmit",
283
            $std->tpEmit,
284
            true,
285
            $identificador . "Indicador da tipo de emitente"
286
        );
287
        $this->dom->addChild(
288
            $ide,
289
            "mod",
290
            $std->mod,
291
            true,
292
            $identificador . "Código do Modelo do Documento Fiscal"
293
        );
294
        $this->dom->addChild(
295
            $ide,
296
            "serie",
297
            $std->serie,
298
            true,
299
            $identificador . "Série do Documento Fiscal"
300
        );
301
        $this->dom->addChild(
302
            $ide,
303
            "nMDF",
304
            $std->nMDF,
305
            true,
306
            $identificador . "Número do Documento Fiscal"
307
        );
308
        $this->dom->addChild(
309
            $ide,
310
            "cMDF",
311
            $std->cMDF,
312
            true,
313
            $identificador . "Código do numérico do MDF"
314
        );
315
        $this->dom->addChild(
316
            $ide,
317
            "cDV",
318
            $std->cDV,
319
            true,
320
            $identificador . "Dígito Verificador da Chave de Acesso da NF-e"
321
        );
322
        $this->dom->addChild(
323
            $ide,
324
            "modal",
325
            $std->modal,
326
            true,
327
            $identificador . "Modalidade de transporte"
328
        );
329
        $this->dom->addChild(
330
            $ide,
331
            "dhEmi",
332
            $std->dhEmi,
333
            true,
334
            $identificador . "Data e hora de emissão do Documento Fiscal"
335
        );
336
        $this->dom->addChild(
337
            $ide,
338
            "tpEmis",
339
            $std->tpEmis,
340
            true,
341
            $identificador . "Tipo de Emissão do Documento Fiscal"
342
        );
343
        $this->dom->addChild(
344
            $ide,
345
            "procEmi",
346
            $std->procEmi,
347
            true,
348
            $identificador . "Processo de emissão"
349
        );
350
        $this->dom->addChild(
351
            $ide,
352
            "verProc",
353
            $std->verProc,
354
            true,
355
            $identificador . "Versão do Processo de emissão"
356
        );
357
        $this->dom->addChild(
358
            $ide,
359
            "UFIni",
360
            $std->UFIni,
361
            true,
362
            $identificador . "Sigla da UF do Carregamento"
363
        );
364
        $this->dom->addChild(
365
            $ide,
366
            "UFFim",
367
            $std->UFFim,
368
            true,
369
            $identificador . "Sigla da UF do Descarregamento"
370
        );
371
        
372
        $this->mod = $std->mod;
373
        $this->ide = $ide;
374
        $this->buildTagIde();
375
        return $ide;
376
    }
377
378
    /**
379
     * taginfMunCarrega
380
     *
381
     * tag MDFe/infMDFe/ide/infMunCarrega
382
     *
383
     * @param  string $cMunCarrega
0 ignored issues
show
Bug introduced by
There is no parameter named $cMunCarrega. 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...
384
     * @param  string $xMunCarrega
0 ignored issues
show
Bug introduced by
There is no parameter named $xMunCarrega. 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...
385
     *
386
     * @return DOMElement
387
     */
388 View Code Duplication
    public function taginfMunCarrega(stdClass $std)
0 ignored issues
show
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...
389
    {
390
        $possible = [
391
            'cMunCarrega',
392
            'xMunCarrega'
393
        ];
394
395
        $std = $this->equilizeParameters($std, $possible);
396
        $infMunCarrega = $this->dom->createElement("infMunCarrega");
397
        $this->dom->addChild(
398
            $infMunCarrega,
399
            "cMunCarrega",
400
            $std->cMunCarrega,
401
            true,
402
            "Código do Município de Carregamento"
403
        );
404
        $this->dom->addChild(
405
            $infMunCarrega,
406
            "xMunCarrega",
407
            $std->xMunCarrega,
408
            true,
409
            "Nome do Município de Carregamento"
410
        );
411
        $this->aInfMunCarrega[] = $infMunCarrega;
0 ignored issues
show
Bug introduced by
The property aInfMunCarrega 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...
412
        return $infMunCarrega;
413
    }
414
415
    /**
416
     * tagInfPercurso
417
     *
418
     * tag MDFe/infMDFe/ide/infPercurso
419
     *
420
     * @param  string $ufPer
0 ignored issues
show
Bug introduced by
There is no parameter named $ufPer. 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...
421
     *
422
     * @return DOMElement
423
     */
424
    public function taginfPercurso(stdClass $std)
425
    {
426
        $possible = [
427
            'UFPer'
428
        ];
429
430
        $std = $this->equilizeParameters($std, $possible);
431
        $infPercurso = $this->dom->createElement("infPercurso");
432
        $this->dom->addChild(
433
            $infPercurso,
434
            "UFPer",
435
            $std->UFPer,
436
            true,
437
            "Sigla das Unidades da Federação do percurso"
438
        );
439
        $this->aInfPercurso[] = $infPercurso;
0 ignored issues
show
Bug introduced by
The property aInfPercurso 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...
440
        return $infPercurso;
441
    }
442
443
    /**
444
     * tagemit
445
     * Identificação do emitente da MDFe
446
     * tag MDFe/infMDFe/emit
447
     *
448
     * @param  string $cnpj
0 ignored issues
show
Bug introduced by
There is no parameter named $cnpj. 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...
449
     * @param  string $numIE
0 ignored issues
show
Bug introduced by
There is no parameter named $numIE. 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...
450
     * @param  string $xNome
0 ignored issues
show
Bug introduced by
There is no parameter named $xNome. 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...
451
     * @param  string $xFant
0 ignored issues
show
Bug introduced by
There is no parameter named $xFant. 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...
452
     *
453
     * @return DOMElement
454
     */
455
    public function tagemit(stdClass $std)
456
    {
457
        $possible = [
458
            'CNPJ',
459
            'IE',
460
            'xNome',
461
            'xFant'
462
        ];
463
        $std = $this->equilizeParameters($std, $possible);
464
        
465
        $identificador = '[25] <emit> - ';
466
        $this->emit = $this->dom->createElement("emit");
467
        $this->dom->addChild(
468
            $this->emit,
469
            "CNPJ",
470
            $std->CNPJ,
471
            true,
472
            $identificador . "CNPJ do emitente"
473
        );
474
        $this->dom->addChild(
475
            $this->emit,
476
            "IE",
477
            $std->IE,
478
            true,
479
            $identificador . "Inscrição Estadual do emitente"
480
        );
481
        $this->dom->addChild(
482
            $this->emit,
483
            "xNome",
484
            $std->xNome,
485
            true,
486
            $identificador . "Razão Social ou Nome do emitente"
487
        );
488
        $this->dom->addChild(
489
            $this->emit,
490
            "xFant",
491
            $std->xFant,
492
            false,
493
            $identificador . "Nome fantasia do emitente"
494
        );
495
        return $this->emit;
496
    }
497
498
    /**
499
     * tagenderEmit
500
     * Endereço do emitente [30] pai [25]
501
     * tag MDFe/infMDFe/emit/endEmit
502
     *
503
     * @param  string $xLgr
0 ignored issues
show
Bug introduced by
There is no parameter named $xLgr. 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...
504
     * @param  string $nro
0 ignored issues
show
Bug introduced by
There is no parameter named $nro. 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...
505
     * @param  string $xCpl
0 ignored issues
show
Bug introduced by
There is no parameter named $xCpl. 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...
506
     * @param  string $xBairro
0 ignored issues
show
Bug introduced by
There is no parameter named $xBairro. 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...
507
     * @param  string $cMun
0 ignored issues
show
Bug introduced by
There is no parameter named $cMun. 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...
508
     * @param  string $xMun
0 ignored issues
show
Bug introduced by
There is no parameter named $xMun. 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...
509
     * @param  string $cep
0 ignored issues
show
Bug introduced by
There is no parameter named $cep. 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...
510
     * @param  string $UF
0 ignored issues
show
Bug introduced by
There is no parameter named $UF. 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...
511
     * @param  string $fone
0 ignored issues
show
Bug introduced by
There is no parameter named $fone. 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...
512
     * @param  string $email
0 ignored issues
show
Bug introduced by
There is no parameter named $email. 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...
513
     *
514
     * @return DOMElement
515
     */
516
    public function tagenderEmit(stdClass $std)
517
    {
518
        $possible = [
519
            'xLgr',
520
            'nro',
521
            'xCpl',
522
            'xBairro',
523
            'cMun',
524
            'xMun',
525
            'CEP',
526
            'UF',
527
            'fone',
528
            'email'
529
        ];
530
        $std = $this->equilizeParameters($std, $possible);
531
532
        $identificador = '[30] <enderEmit> - ';
533
        $this->enderEmit = $this->dom->createElement("enderEmit");
534
        
535
        $this->dom->addChild(
536
            $this->enderEmit,
537
            "xLgr",
538
            $std->xLgr,
539
            true,
540
            $identificador . "Logradouro do Endereço do emitente"
541
        );
542
        $this->dom->addChild(
543
            $this->enderEmit,
544
            "nro",
545
            $std->nro,
546
            true,
547
            $identificador . "Número do Endereço do emitente"
548
        );
549
        $this->dom->addChild(
550
            $this->enderEmit,
551
            "xCpl",
552
            $std->xCpl,
553
            false,
554
            $identificador . "Complemento do Endereço do emitente"
555
        );
556
        $this->dom->addChild(
557
            $this->enderEmit,
558
            "xBairro",
559
            $std->xBairro,
560
            true,
561
            $identificador . "Bairro do Endereço do emitente"
562
        );
563
        $this->dom->addChild(
564
            $this->enderEmit,
565
            "cMun",
566
            $std->cMun,
567
            true,
568
            $identificador . "Código do município do Endereço do emitente"
569
        );
570
        $this->dom->addChild(
571
            $this->enderEmit,
572
            "xMun",
573
            $std->xMun,
574
            true,
575
            $identificador . "Nome do município do Endereço do emitente"
576
        );
577
        $this->dom->addChild(
578
            $this->enderEmit,
579
            "CEP",
580
            $std->CEP,
581
            true,
582
            $identificador . "Código do CEP do Endereço do emitente"
583
        );
584
        $this->dom->addChild(
585
            $this->enderEmit,
586
            "UF",
587
            $std->UF,
588
            true,
589
            $identificador . "Sigla da UF do Endereço do emitente"
590
        );
591
        $this->dom->addChild(
592
            $this->enderEmit,
593
            "fone",
594
            $std->fone,
595
            false,
596
            $identificador . "Número de telefone do emitente"
597
        );
598
        $this->dom->addChild(
599
            $this->enderEmit,
600
            "email",
601
            $std->email,
602
            false,
603
            $identificador . "Endereço de email do emitente"
604
        );
605
        return $this->enderEmit;
606
    }
607
608
    /**
609
     * tagInfMunDescarga
610
     * tag MDFe/infMDFe/infDoc/infMunDescarga
611
     *
612
     * @param  integer $nItem
0 ignored issues
show
Bug introduced by
There is no parameter named $nItem. 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...
613
     * @param  string  $cMunDescarga
0 ignored issues
show
Bug introduced by
There is no parameter named $cMunDescarga. 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...
614
     * @param  string  $xMunDescarga
0 ignored issues
show
Bug introduced by
There is no parameter named $xMunDescarga. 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...
615
     *
616
     * @return DOMElement
617
     */
618
    public function taginfMunDescarga(stdClass $std)
619
    {
620
        $possible = [
621
            'cMunDescarga',
622
            'xMunDescarga'
623
        ];
624
        $std = $this->equilizeParameters($std, $possible);
625
626
        if (empty($this->infDoc)) {
627
            $infDoc = $this->dom->createElement("infDoc");
628
        } else {
629
            $infDoc = $this->infDoc;
630
        }
631
        $infMunDescarga = $this->dom->createElement("infMunDescarga");
632
        $this->dom->addChild(
633
            $infMunDescarga,
634
            "cMunDescarga",
635
            $std->cMunDescarga,
636
            true,
637
            "Código do Município de Descarga"
638
        );
639
        $this->dom->addChild(
640
            $infMunDescarga,
641
            "xMunDescarga",
642
            $std->xMunDescarga,
643
            true,
644
            "Nome do Município de Descarga"
645
        );
646
        $this->dom->appChild($infDoc, $infMunDescarga, 'Falta tag "ide"');
647
        $this->infDoc = $infDoc;
648
        $this->aInfMunDescarga = $infMunDescarga;
0 ignored issues
show
Bug introduced by
The property aInfMunDescarga 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...
649
        return $infMunDescarga;
650
    }
651
652
    public function taginfANTT(stdClass $std)
653
    {
654
        $possible = [
655
            'RNTRC',
656
            'infCIOT',
657
            'valePed',
658
            'infContratante'
659
        ];
660
        $std = $this->equilizeParameters($std, $possible);
661
        $rodo = $this->dom->createElement("rodo");
662
        $infANTT = $this->dom->createElement("infANTT");
663
        $this->dom->addChild(
664
            $infANTT,
665
            "RNTRC",
666
            $std->RNTRC,
667
            false,
668
            "RNTRC"
669
        );
670
671
        if ($std->infCIOT != null) {
672
            $possible = [
673
                'CIOT',
674
                'CPF',
675
                'CNPJ'
676
            ];
677
            $stdinfCIOT = $this->equilizeParameters($std->infCIOT, $possible);
678
            $infCIOT = $this->dom->createElement("infCIOT");
679
            $this->dom->addChild(
680
                $infCIOT,
681
                "CIOT",
682
                $stdinfCIOT->CIOT,
683
                true,
684
                "CIOT"
685
            );
686
            
687
            $this->dom->addChild(
688
                $infCIOT,
689
                "CPF",
690
                $stdinfCIOT->CPF,
691
                false,
692
                "CPF"
693
            );
694
            $this->dom->addChild(
695
                $infCIOT,
696
                "CNPJ",
697
                $stdinfCIOT->CNPJ,
698
                false,
699
                "CNPJ"
700
            );
701
            $this->dom->appChild($infANTT, $infCIOT, 'Falta tag "infCIOT"');
702
        }
703
        if ($std->valePed != null) {
704
            $possible = [
705
                'CNPJForn',
706
                'CNPJPg',
707
                'CPFPg',
708
                'nCompra',
709
                'vValePed'
710
            ];
711
            $stdvalePed = $this->equilizeParameters($std->valePed, $possible);
712
            $valePed = $this->dom->createElement("valePed");
713
            $disp = $this->dom->createElement("disp");
714
            $this->dom->addChild(
715
                $disp,
716
                "CNPJForn",
717
                $stdvalePed->CNPJForn,
718
                false,
719
                "CNPJForn"
720
            );
721
            $this->dom->addChild(
722
                $disp,
723
                "CNPJPg",
724
                $stdvalePed->CNPJPg,
725
                false,
726
                "CNPJPg"
727
            );
728
            $this->dom->addChild(
729
                $disp,
730
                "CPFPg",
731
                $stdvalePed->CPFPg,
732
                false,
733
                "CPFPg"
734
            );
735
            $this->dom->addChild(
736
                $disp,
737
                "nCompra",
738
                $stdvalePed->nCompra,
739
                false,
740
                "nCompra"
741
            );
742
            $this->dom->addChild(
743
                $disp,
744
                "vValePed",
745
                $stdvalePed->vValePed,
746
                false,
747
                "vValePed"
748
            );
749
            $this->dom->appChild($valePed, $disp, 'Falta tag "disp"');
750
            $this->dom->appChild($infANTT, $valePed, 'Falta tag "valePed"');
751
        }
752 View Code Duplication
        if ($std->infContratante != null) {
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...
753
            $possible = [
754
                'CPF',
755
                'CNPJ'
756
            ];
757
            $stdinfContratante = $this->equilizeParameters($std->infContratante, $possible);
758
            $infContratante = $this->dom->createElement("infContratante");
759
            $this->dom->addChild(
760
                $infContratante,
761
                "CPF",
762
                $stdinfContratante->CPF,
763
                false,
764
                "CPF"
765
            );
766
            $this->dom->addChild(
767
                $infContratante,
768
                "CNPJ",
769
                $stdinfContratante->CNPJ,
770
                false,
771
                "CNPJ"
772
            );
773
            $this->dom->appChild($infANTT, $infContratante, 'Falta tag "infContratante"');
774
        }
775
        
776
        $this->dom->appChild($rodo, $infANTT, 'Falta tag "ide"');
777
        $this->rodo = $rodo;
778
        return $this->rodo;
779
    }
780
    
781
    /**
782
     * taginfCTe
783
     * tag MDFe/infMDFe/infDoc/infMunDescarga/infCTe
784
     *
785
     * @param  integer chCTe
786
     * @param  string  SegCodBarra
787
     * @param  string  indReentrega
788
     * @param  string  infUnidTransp
789
     * @param  string  peri
790
     * @param  string  infEntregaParcial
791
     *
792
     * @return DOMElement
793
     */
794
    public function taginfCTe(stdClass $std)
795
    {
796
        $possible = [
797
            'chCTe',
798
            'SegCodBarra',
799
            'indReentrega',
800
            'infUnidTransp',
801
            'peri',
802
            'infEntregaParcial'
803
        ];
804
        $std = $this->equilizeParameters($std, $possible);
805
        $infCTe = $this->dom->createElement("infCTe");
806
        $this->dom->addChild(
807
            $infCTe,
808
            "chCTe",
809
            $std->chCTe,
810
            true,
811
            "Chave de Acesso CTe"
812
        );
813
        $this->dom->addChild(
814
            $infCTe,
815
            "SegCodBarra",
816
            $std->SegCodBarra,
817
            false,
818
            "Segundo código de barras do CTe"
819
        );
820
        $this->dom->addChild(
821
            $infCTe,
822
            "indReentrega",
823
            $std->indReentrega,
824
            false,
825
            "Indicador de Reentrega"
826
        );
827 View Code Duplication
        if ($std->infUnidTransp != null) {
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...
828
            $infUnidTransp = $this->taginfUnidTransp($std->infUnidTransp);
829
            $this->dom->appChild($infCTe, $infUnidTransp, 'Falta tag "infUnidTransp"');
830
        }
831
        if ($std->peri != null) {
832
            $peri = $this->tagperi($std->peri);
833
            $this->dom->appChild($infCTe, $peri, 'Falta tag "$peri"');
834
        }
835 View Code Duplication
        if ($std->infEntregaParcial != null) {
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...
836
            $possible = [
837
                'qtdTotal',
838
                'qtdParcial'
839
            ];
840
            $stdinfEntregaParcial = $this->equilizeParameters($std->infEntregaParcial, $possible);
841
            $infEntregaParcial = $this->dom->createElement("infEntregaParcial");
842
            $this->dom->addChild(
843
                $infEntregaParcial,
844
                "qtdTotal",
845
                $stdinfEntregaParcial->qtdTotal,
846
                true,
847
                "Quantidade total de volumes"
848
            );
849
            $this->dom->addChild(
850
                $infEntregaParcial,
851
                "qtdParcial",
852
                $stdinfEntregaParcial->qtdParcial,
853
                true,
854
                "Quantidade de volumes enviados no MDF-e"
855
            );
856
            $this->dom->appChild($infCTe, $infEntregaParcial, 'Falta tag "$peri"');
857
        }
858
        $this->dom->appChild($this->aInfMunDescarga, $infCTe, 'Falta tag "infCTe"');
859
        return $infCTe;
860
    }
861
862
    /**
863
     * tagperi
864
     * tag MDFe/infMDFe/infDoc/infMunDescarga/(infCTe/infNFe)/peri
865
     *
866
     * @param  integer nONU
867
     * @param  string  xNomeAE
868
     * @param  string  xClaRisco
869
     * @param  string  grEmb
870
     * @param  string  qTotProd
871
     * @param  string  qVolTipo
872
     *
873
     * @return DOMElement
874
     */
875 View Code Duplication
    public function tagperi(stdClass $std)
0 ignored issues
show
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...
876
    {
877
        $possible = [
878
            'nONU',
879
            'xNomeAE',
880
            'xClaRisco',
881
            'grEmb',
882
            'qTotProd',
883
            'qVolTipo'
884
        ];
885
        $std = $this->equilizeParameters($std, $possible);
886
        $peri = $this->dom->createElement("peri");
887
        $this->dom->addChild(
888
            $peri,
889
            "nONU",
890
            $std->nONU,
891
            true,
892
            "Número ONU/UN"
893
        );
894
        $this->dom->addChild(
895
            $peri,
896
            "xNomeAE",
897
            $std->xNomeAE,
898
            true,
899
            "Nome apropriado para embarque do produto"
900
        );
901
        $this->dom->addChild(
902
            $peri,
903
            "xClaRisco",
904
            $std->xClaRisco,
905
            true,
906
            "Classe ou subclasse/divisão, e risco subsidiário/risco secundário"
907
        );
908
        $this->dom->addChild(
909
            $peri,
910
            "grEmb",
911
            $std->grEmb,
912
            true,
913
            "Grupo de Embalagem"
914
        );
915
        $this->dom->addChild(
916
            $peri,
917
            "qTotProd",
918
            $std->qTotProd,
919
            true,
920
            "Quantidade total por produto"
921
        );
922
        $this->dom->addChild(
923
            $peri,
924
            "qVolTipo",
925
            $std->qVolTipo,
926
            true,
927
            "Quantidade e Tipo de volumes"
928
        );
929
        return $peri;
930
    }
931
    
932
    /**
933
     * taginfNFe
934
     * tag MDFe/infMDFe/infDoc/infMunDescarga/infNFe
935
     *
936
     * @param  integer chNFe
937
     * @param  string  SegCodBarra
938
     * @param  string  indReentrega
939
     * @param  string  infUnidTransp
940
     * @param  string  peri
941
     *
942
     * @return DOMElement
943
     */
944
    public function taginfNFe(stdClass $std)
945
    {
946
        $possible = [
947
            'chNFe',
948
            'SegCodBarra',
949
            'indReentrega',
950
            'infUnidTransp',
951
            'peri'
952
        ];
953
        $std = $this->equilizeParameters($std, $possible);
954
        $infNFe = $this->dom->createElement("infNFe");
955
        $this->dom->addChild(
956
            $infNFe,
957
            "chNFe",
958
            $std->chNFe,
959
            true,
960
            "Chave de Acesso NFe"
961
        );
962
        $this->dom->addChild(
963
            $infNFe,
964
            "SegCodBarra",
965
            $std->SegCodBarra,
966
            false,
967
            "Segundo código de barras do NFe"
968
        );
969
        $this->dom->addChild(
970
            $infNFe,
971
            "indReentrega",
972
            $std->indReentrega,
973
            false,
974
            "Indicador de Reentrega"
975
        );
976 View Code Duplication
        if ($std->infUnidTransp != null) {
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...
977
            $infUnidTransp = $this->taginfUnidTransp($std->infUnidTransp);
978
            $this->dom->appChild($infNFe, $infUnidTransp, 'Falta tag "infUnidTransp"');
979
        }
980
        if ($std->peri != null) {
981
            $peri = $this->tagperi($std->peri);
982
            $this->dom->appChild($infNFe, $peri, 'Falta tag "$peri"');
983
        }
984
        $this->dom->appChild($this->aInfMunDescarga, $infNFe, 'Falta tag "infNFe"');
985
        return $infNFe;
986
    }
987
988
    /**
989
     * taginfMDFeTransp
990
     * tag MDFe/infMDFe/infDoc/infMunDescarga/infMDFeTransp
991
     *
992
     * @param  integer chMDFe
993
     * @param  string  indReentrega
994
     * @param  string  infUnidTransp
995
     * @param  string  peri
996
     *
997
     * @return DOMElement
998
     */
999
    public function taginfMDFeTransp(stdClass $std)
1000
    {
1001
        $possible = [
1002
            'chNFe',
1003
            'indReentrega',
1004
            'infUnidTransp',
1005
            'peri'
1006
        ];
1007
        $std = $this->equilizeParameters($std, $possible);
1008
        $infNFeTransp = $this->dom->createElement("infNFeTransp");
1009
        $this->dom->addChild(
1010
            $infNFeTransp,
1011
            "chNFe",
1012
            $std->chNFe,
1013
            true,
1014
            "Chave de Acesso NFe"
1015
        );
1016
        $this->dom->addChild(
1017
            $infNFeTransp,
1018
            "indReentrega",
1019
            $std->indReentrega,
1020
            false,
1021
            "Indicador de Reentrega"
1022
        );
1023 View Code Duplication
        if ($std->infUnidTransp != null) {
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...
1024
            $infUnidTransp = $this->taginfUnidTransp($std->infUnidTransp);
1025
            $this->dom->appChild($infNFeTransp, $infUnidTransp, 'Falta tag "infUnidTransp"');
1026
        }
1027
        if ($std->peri != null) {
1028
            $peri = $this->tagperi($std->peri);
1029
            $this->dom->appChild($infNFeTransp, $peri, 'Falta tag "$peri"');
1030
        }
1031
        $this->dom->appChild($this->aInfMunDescarga, $infNFeTransp, 'Falta tag "infNFe"');
1032
        return $infNFeTransp;
1033
    }
1034
1035
    /**
1036
     * taginfUnidTransp
1037
     * tag MDFe/infMDFe/infDoc/infMunDescarga/(infCTe/infNFe)/infUnidTransp
1038
     *
1039
     * @param  integer tpUnidTrans
1040
     * @param  string  idUnidTrans
1041
     * @param  string  qtdRat
1042
     * @param  string  lacUnidTransp
1043
     * @param  string  infUnidCarga
1044
     *
1045
     * @return DOMElement
1046
     */
1047
    public function taginfUnidTransp(stdClass $std)
1048
    {
1049
        $possible = [
1050
            'tpUnidTransp',
1051
            'idUnidTransp',
1052
            'qtdRat',
1053
            'lacUnidTransp',
1054
            'infUnidCarga'
1055
        ];
1056
        $std = $this->equilizeParameters($std, $possible);
1057
        $infUnidTransp = $this->dom->createElement("infUnidTransp");
1058
        $this->dom->addChild(
1059
            $infUnidTransp,
1060
            "tpUnidTransp",
1061
            $std->tpUnidTransp,
1062
            true,
1063
            "Tipo da Unidade de Transporte"
1064
        );
1065
        $this->dom->addChild(
1066
            $infUnidTransp,
1067
            "idUnidTransp",
1068
            $std->idUnidTransp,
1069
            false,
1070
            "Identificação da Unidade de Transporte"
1071
        );
1072 View Code Duplication
        if ($std->lacUnidTransp != null) {
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...
1073
            $possible = [
1074
                'nLacre'
1075
            ];
1076
            $stdlacUnidTransp = $this->equilizeParameters($std->lacUnidTransp, $possible);
1077
            foreach ($stdlacUnidTransp->nLacre as $nItem => $nLacre) {
1078
                $lacUnidTransp = $this->dom->createElement("lacUnidTransp");
1079
                $this->dom->addChild(
1080
                    $lacUnidTransp,
1081
                    "nLacre",
1082
                    $nLacre,
1083
                    true,
1084
                    "Número do lacre"
1085
                );
1086
                $this->dom->appChild($infUnidTransp, $lacUnidTransp, 'Falta tag "infUnidTransp"');
1087
            }
1088
        }
1089
        if ($std->infUnidCarga != null) {
1090
            $infUnidCarga = $this->taginfUnidCarga($std->infUnidCarga);
1091
            $this->dom->appChild($infUnidTransp, $infUnidCarga, 'Falta tag "infUnidCarga"');
1092
        }
1093
        $this->dom->addChild(
1094
            $infUnidTransp,
1095
            "qtdRat",
1096
            $std->qtdRat,
1097
            false,
1098
            "Quantidade rateada (Peso,Volume) "
1099
        );
1100
        return $infUnidTransp;
1101
    }
1102
1103
    /**
1104
     * taginfUnidCarga
1105
     * tag MDFe/infMDFe/infDoc/infMunDescarga/(infCTe/infNFe)/infUnidCarga
1106
     *
1107
     * @param  integer tpUnidCarga
1108
     * @param  string  idUnidCarga
1109
     * @param  string  lacUnidCarga
1110
     * @param  string  qtdRat
1111
     *
1112
     * @return DOMElement
1113
     */
1114
    public function taginfUnidCarga(stdClass $std)
1115
    {
1116
        $possible = [
1117
            'tpUnidCarga',
1118
            'idUnidCarga',
1119
            'lacUnidCarga',
1120
            'qtdRat'
1121
        ];
1122
        $std = $this->equilizeParameters($std, $possible);
1123
        $infUnidCarga = $this->dom->createElement("infUnidCarga");
1124
        $this->dom->addChild(
1125
            $infUnidCarga,
1126
            "tpUnidCarga",
1127
            $std->tpUnidCarga,
1128
            false,
1129
            "Tipo da Unidade de Carga"
1130
        );
1131
        $this->dom->addChild(
1132
            $infUnidCarga,
1133
            "idUnidCarga",
1134
            $std->idUnidCarga,
1135
            false,
1136
            "Identificação da Unidade de Carga "
1137
        );
1138 View Code Duplication
        if ($std->lacUnidCarga != null) {
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...
1139
            $possible = [
1140
                'nLacre'
1141
            ];
1142
            $stdlacUnidCarga = $this->equilizeParameters($std->lacUnidCarga, $possible);
1143
            foreach ($stdlacUnidCarga->nLacre as $nItem => $nLacre) {
1144
                $lacUnidCarga = $this->dom->createElement("lacUnidCarga");
1145
                $this->dom->addChild(
1146
                    $lacUnidCarga,
1147
                    "nLacre",
1148
                    $nLacre,
1149
                    true,
1150
                    "Número do lacre"
1151
                );
1152
                $this->dom->appChild($infUnidCarga, $lacUnidCarga, 'Falta tag "lacUnidCarga"');
1153
            }
1154
        }
1155
        $this->dom->addChild(
1156
            $infUnidCarga,
1157
            "qtdRat",
1158
            $std->qtdRat,
1159
            false,
1160
            "Quantidade rateada (Peso,Volume) "
1161
        );
1162
        
1163
        return $infUnidCarga ;
1164
    }
1165
    
1166
    /**
1167
     * tagseg
1168
     * tag MDFe/infMDFe/seg
1169
     *
1170
     * @param  string $respSeg
0 ignored issues
show
Bug introduced by
There is no parameter named $respSeg. 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...
1171
     * @param  string $CNPJ
0 ignored issues
show
Bug introduced by
There is no parameter named $CNPJ. 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...
1172
     * @param  string $CPF
0 ignored issues
show
Bug introduced by
There is no parameter named $CPF. 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...
1173
     * @param  string $infSeg
0 ignored issues
show
Bug introduced by
There is no parameter named $infSeg. 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...
1174
     * @param  string $nApol
0 ignored issues
show
Bug introduced by
There is no parameter named $nApol. 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...
1175
     * @param  string $nAver
0 ignored issues
show
Bug introduced by
There is no parameter named $nAver. 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...
1176
     *
1177
     * @return DOMElement
1178
     */
1179
    public function tagseg(stdClass $std)
1180
    {
1181
        $possible = [
1182
            'respSeg',
1183
            'CNPJ',
1184
            'CPF',
1185
            'infSeg',
1186
            'nApol',
1187
            'nAver'
1188
        ];
1189
        $std = $this->equilizeParameters($std, $possible);
1190
        $seg = $this->dom->createElement("seg");
1191
        $infResp = $this->dom->createElement("infResp");
1192
        $this->dom->addChild(
1193
            $infResp,
1194
            "respSeg",
1195
            $std->respSeg,
1196
            true,
1197
            "Responsável pelo seguro"
1198
        );
1199
        $this->dom->addChild(
1200
            $infResp,
1201
            "CNPJ",
1202
            $std->CNPJ,
1203
            false,
1204
            "Número do CNPJ do responsável pelo seguro"
1205
        );
1206
        $this->dom->addChild(
1207
            $infResp,
1208
            "CPF",
1209
            $std->CPF,
1210
            false,
1211
            "Número do CPF do responsável pelo seguro"
1212
        );
1213
        $this->dom->appChild($seg, $infResp, 'Falta tag "infResp"');
1214 View Code Duplication
        if ($std->infSeg != null) {
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...
1215
            $possible = [
1216
                'xSeg',
1217
                'CNPJ'
1218
            ];
1219
            $stdinfSeg = $this->equilizeParameters($std->infSeg, $possible);
1220
            $infSeg = $this->dom->createElement("infSeg");
1221
            $this->dom->addChild(
1222
                $infSeg,
1223
                "xSeg",
1224
                $stdinfSeg->xSeg,
1225
                true,
1226
                "Nome da Seguradora"
1227
            );
1228
            $this->dom->addChild(
1229
                $infSeg,
1230
                "CNPJ",
1231
                $stdinfSeg->CNPJ,
1232
                false,
1233
                "Número do CNPJ da seguradora"
1234
            );
1235
            $this->dom->appChild($seg, $infSeg, 'Falta tag "infSeg"');
1236
        }
1237
        $this->dom->addChild(
1238
            $seg,
1239
            "nApol",
1240
            $std->nApol,
1241
            false,
1242
            "Número da Apólice"
1243
        );
1244
        if ($std->nAver != null) {
1245
            foreach ($std->nAver as $nItem => $nAver) {
1246
                $this->dom->addChild(
1247
                    $seg,
1248
                    "nAver",
1249
                    $nAver,
1250
                    true,
1251
                    "Número da Averbação"
1252
                );
1253
            }
1254
        }
1255
        $this->seg = $seg;
1256
        return $seg;
1257
    }
1258
1259
    /**
1260
     * tagTot
1261
     * tag MDFe/infMDFe/tot
1262
     *
1263
     * @param  string $qCTe
0 ignored issues
show
Bug introduced by
There is no parameter named $qCTe. 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...
1264
     * @param  string $qNFe
0 ignored issues
show
Bug introduced by
There is no parameter named $qNFe. 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...
1265
     * @param  string $qMDFe
0 ignored issues
show
Bug introduced by
There is no parameter named $qMDFe. 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...
1266
     * @param  string $vCarga
0 ignored issues
show
Bug introduced by
There is no parameter named $vCarga. 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...
1267
     * @param  string $cUnid
0 ignored issues
show
Bug introduced by
There is no parameter named $cUnid. 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...
1268
     * @param  string $qCarga
0 ignored issues
show
Bug introduced by
There is no parameter named $qCarga. 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...
1269
     *
1270
     * @return DOMElement
1271
     */
1272 View Code Duplication
    public function tagtot(stdClass $std)
0 ignored issues
show
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...
1273
    {
1274
        $possible = [
1275
            'qCTe',
1276
            'qNFe',
1277
            'qMDFe',
1278
            'vCarga',
1279
            'cUnid',
1280
            'qCarga'
1281
        ];
1282
        $std = $this->equilizeParameters($std, $possible);
1283
        $tot = $this->dom->createElement("tot");
1284
        $this->dom->addChild(
1285
            $tot,
1286
            "qCTe",
1287
            $std->qCTe,
1288
            false,
1289
            "Quantidade total de CT-e relacionados no Manifesto"
1290
        );
1291
        $this->dom->addChild(
1292
            $tot,
1293
            "qNFe",
1294
            $std->qNFe,
1295
            false,
1296
            "Quantidade total de NF-e relacionados no Manifesto"
1297
        );
1298
        $this->dom->addChild(
1299
            $tot,
1300
            "qMDFe",
1301
            $std->qMDFe,
1302
            false,
1303
            "Quantidade total de MDF-e relacionados no Manifesto"
1304
        );
1305
        $this->dom->addChild(
1306
            $tot,
1307
            "vCarga",
1308
            $std->vCarga,
1309
            true,
1310
            "Valor total da mercadoria/carga transportada"
1311
        );
1312
        $this->dom->addChild(
1313
            $tot,
1314
            "cUnid",
1315
            $std->cUnid,
1316
            true,
1317
            "Código da unidade de medida do Peso Bruto da Carga / Mercadoria Transportada"
1318
        );
1319
        $this->dom->addChild(
1320
            $tot,
1321
            "qCarga",
1322
            $std->qCarga,
1323
            true,
1324
            "Peso Bruto Total da Carga / Mercadoria Transportada"
1325
        );
1326
        $this->tot = $tot;
1327
        return $tot;
1328
    }
1329
1330
    /**
1331
     * tagLacres
1332
     * tag MDFe/infMDFe/lacres
1333
     *
1334
     * @param  string $nLacre
0 ignored issues
show
Bug introduced by
There is no parameter named $nLacre. 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...
1335
     *
1336
     * @return DOMElement
1337
     */
1338
    public function taglacres(stdClass $std)
1339
    {
1340
        $possible = [
1341
            'nLacre'
1342
        ];
1343
        $std = $this->equilizeParameters($std, $possible);
1344
        if ($std->nLacre != null) {
1345
            foreach ($std->nLacre as $nItem => $nLacre) {
1346
                $lacres = $this->dom->createElement("lacres");
1347
                $this->dom->addChild(
1348
                    $lacres,
1349
                    "nLacre",
1350
                    $nLacre,
1351
                    false,
1352
                    "Número do lacre"
1353
                );
1354
                $this->lacres[] = $lacres; //array de DOMNode
1355
            }
1356
        }
1357
        return $this->lacres;
1358
    }
1359
1360
    /**
1361
     * taginfAdic
1362
     * Grupo de Informações Adicionais Z01 pai A01
1363
     * tag MDFe/infMDFe/infAdic (opcional)
1364
     *
1365
     * @param  string $infAdFisco
0 ignored issues
show
Bug introduced by
There is no parameter named $infAdFisco. 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...
1366
     * @param  string $infCpl
0 ignored issues
show
Bug introduced by
There is no parameter named $infCpl. 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...
1367
     *
1368
     * @return DOMElement
1369
     */
1370 View Code Duplication
    public function taginfAdic(stdClass $std)
0 ignored issues
show
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...
1371
    {
1372
        $possible = [
1373
            'infAdFisco',
1374
            'infCpl'
1375
        ];
1376
        $std = $this->equilizeParameters($std, $possible);
1377
        $infAdic = $this->dom->createElement("infAdic");
1378
        $this->dom->addChild(
1379
            $infAdic,
1380
            "infAdFisco",
1381
            $std->infAdFisco,
1382
            false,
1383
            "Informações Adicionais de Interesse do Fisco"
1384
        );
1385
        $this->dom->addChild(
1386
            $infAdic,
1387
            "infCpl",
1388
            $std->infCpl,
1389
            false,
1390
            "Informações Complementares de interesse do Contribuinte"
1391
        );
1392
        $this->infAdic = $infAdic;
1393
        return $infAdic;
1394
    }
1395
1396
    /**
1397
     * tagautXML
1398
     * tag MDFe/infMDFe/autXML
1399
     *
1400
     * Autorizados para download do XML do MDF-e
1401
     *
1402
     * @param string $cnpj
0 ignored issues
show
Bug introduced by
There is no parameter named $cnpj. 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...
1403
     * @param string $cpf
0 ignored issues
show
Bug introduced by
There is no parameter named $cpf. 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...
1404
     *
1405
     * @return DOMElement
1406
     */
1407 View Code Duplication
    public function tagautXML(stdClass $std)
0 ignored issues
show
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...
1408
    {
1409
        $possible = [
1410
            'CNPJ',
1411
            'CPF'
1412
        ];
1413
        $std = $this->equilizeParameters($std, $possible);
1414
        $autXML = $this->dom->createElement("autXML");
1415
        $this->dom->addChild(
1416
            $autXML,
1417
            "CNPJ",
1418
            $std->CNPJ,
1419
            false,
1420
            "CNPJ do autorizado"
1421
        );
1422
        $this->dom->addChild(
1423
            $autXML,
1424
            "CPF",
1425
            $std->CPF,
1426
            false,
1427
            "CPF do autorizado"
1428
        );
1429
        $this->autXML[] = $autXML;
1430
        return $this->autXML;
1431
    }
1432
1433
    /**
1434
     * buildInfModal
1435
     * tag MDFe/infMDFe/infModal
1436
     *
1437
     * @param  string $versaoModal
0 ignored issues
show
Bug introduced by
There is no parameter named $versaoModal. 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...
1438
     *
1439
     * @return DOMElement
1440
     */
1441
    public function buildInfModal()
1442
    {
1443
        $infModal = $this->dom->createElement("infModal");
1444
        $infModal->setAttribute("versaoModal", $this->versao);
1445
        $this->infModal = $infModal;
1446
        return $infModal;
1447
    }
1448
1449
    /**
1450
     * tagAereo
1451
     * tag MDFe/infMDFe/infModal/aereo
1452
     *
1453
     * @param  string $nac
1454
     * @param  string $matr
1455
     * @param  string $nVoo
1456
     * @param  string $cAerEmb
1457
     * @param  string $cAerDes
1458
     * @param  string $dVoo
1459
     *
1460
     * @return DOMElement
1461
     */
1462
   
1463
    public function tagAereo(
1464
        $nac = '',
1465
        $matr = '',
1466
        $nVoo = '',
1467
        $cAerEmb = '',
1468
        $cAerDes = '',
1469
        $dVoo = ''
1470
    ) {
1471
        $aereo = $this->dom->createElement("aereo");
1472
        $this->dom->addChild(
1473
            $aereo,
1474
            "nac",
1475
            $nac,
1476
            true,
1477
            "Marca da Nacionalidade da aeronave"
1478
        );
1479
        $this->dom->addChild(
1480
            $aereo,
1481
            "matr",
1482
            $matr,
1483
            true,
1484
            "Marca de Matrícula da aeronave"
1485
        );
1486
        $this->dom->addChild(
1487
            $aereo,
1488
            "nVoo",
1489
            $nVoo,
1490
            true,
1491
            "Número do Vôo"
1492
        );
1493
        $this->dom->addChild(
1494
            $aereo,
1495
            "cAerEmb",
1496
            $cAerEmb,
1497
            true,
1498
            "Aeródromo de Embarque - Código IATA"
1499
        );
1500
        $this->dom->addChild(
1501
            $aereo,
1502
            "cAerDes",
1503
            $cAerDes,
1504
            true,
1505
            "Aeródromo de Destino - Código IATA"
1506
        );
1507
        $this->dom->addChild(
1508
            $aereo,
1509
            "dVoo",
1510
            $dVoo,
1511
            true,
1512
            "Data do Vôo"
1513
        );
1514
        $this->aereo = $aereo;
1515
        return $aereo;
1516
    }
1517
    
1518
    /**
1519
     * tagTrem
1520
     * tag MDFe/infMDFe/infModal/ferrov/trem
1521
     *
1522
     * @param  string $xPref
1523
     * @param  string $dhTrem
1524
     * @param  string $xOri
1525
     * @param  string $xDest
1526
     * @param  string $qVag
1527
     *
1528
     * @return DOMElement
1529
     */
1530
    
1531
    public function tagTrem(
1532
        $xPref = '',
1533
        $dhTrem = '',
1534
        $xOri = '',
1535
        $xDest = '',
1536
        $qVag = ''
1537
    ) {
1538
        $trem = $this->dom->createElement("trem");
1539
        $this->dom->addChild(
1540
            $trem,
1541
            "xPref",
1542
            $xPref,
1543
            true,
1544
            "Prefixo do Trem"
1545
        );
1546
        $this->dom->addChild(
1547
            $trem,
1548
            "dhTrem",
1549
            $dhTrem,
1550
            false,
1551
            "Data e hora de liberação do trem na origem"
1552
        );
1553
        $this->dom->addChild(
1554
            $trem,
1555
            "xOri",
1556
            $xOri,
1557
            true,
1558
            "Origem do Trem"
1559
        );
1560
        $this->dom->addChild(
1561
            $trem,
1562
            "xDest",
1563
            $xDest,
1564
            true,
1565
            "Destino do Trem"
1566
        );
1567
        $this->dom->addChild(
1568
            $trem,
1569
            "qVag",
1570
            $qVag,
1571
            true,
1572
            "Quantidade de vagões"
1573
        );
1574
        $this->trem = $trem;
1575
        return $trem;
1576
    }
1577
    
1578
    /**
1579
     * tagVag
1580
     * tag MDFe/infMDFe/infModal/ferrov/trem/vag
1581
     *
1582
     * @param  string $serie
1583
     * @param  string $nVag
1584
     * @param  string $nSeq
1585
     * @param  string $tonUtil
1586
     *
1587
     * @return DOMElement
1588
     */
1589
    
1590
    public function tagVag(
1591
        $serie = '',
1592
        $nVag = '',
1593
        $nSeq = '',
1594
        $tonUtil = ''
1595
    ) {
1596
        $vag = $this->dom->createElement("vag");
1597
        $this->dom->addChild(
1598
            $vag,
1599
            "serie",
1600
            $serie,
1601
            true,
1602
            "Série de Identificação do vagão"
1603
        );
1604
        $this->dom->addChild(
1605
            $vag,
1606
            "nVag",
1607
            $nVag,
1608
            true,
1609
            "Número de Identificação do vagão"
1610
        );
1611
        $this->dom->addChild(
1612
            $vag,
1613
            "nSeq",
1614
            $nSeq,
1615
            false,
1616
            "Sequência do vagão na composição"
1617
        );
1618
        $this->dom->addChild(
1619
            $vag,
1620
            "TU",
1621
            $tonUtil,
1622
            true,
1623
            "Tonelada Útil"
1624
        );
1625
        $this->aVag[] = $vag;
0 ignored issues
show
Bug introduced by
The property aVag 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...
1626
        return $vag;
1627
    }
1628
    
1629
    /**
1630
     * tagAqua
1631
     * tag MDFe/infMDFe/infModal/Aqua
1632
     *
1633
     * @param  string $cnpjAgeNav
1634
     * @param  string $tpEmb
1635
     * @param  string $cEmbar
1636
     * @param  string $nViagem
1637
     * @param  string $cPrtEmb
1638
     * @param  string $cPrtDest
1639
     *
1640
     * @return DOMElement
1641
     */
1642
    
1643
    public function tagAqua(
1644
        $cnpjAgeNav = '',
1645
        $tpEmb = '',
1646
        $cEmbar = '',
1647
        $nViagem = '',
1648
        $cPrtEmb = '',
1649
        $cPrtDest = ''
1650
    ) {
1651
        $aqua = $this->dom->createElement("Aqua");
1652
        $this->dom->addChild(
1653
            $aqua,
1654
            "CNPJAgeNav",
1655
            $cnpjAgeNav,
1656
            true,
1657
            "CNPJ da Agência de Navegação"
1658
        );
1659
        $this->dom->addChild(
1660
            $aqua,
1661
            "tpEmb",
1662
            $tpEmb,
1663
            true,
1664
            "Código do tipo de embarcação"
1665
        );
1666
        $this->dom->addChild(
1667
            $aqua,
1668
            "cEmbar",
1669
            $cEmbar,
1670
            true,
1671
            "Código da Embarcação"
1672
        );
1673
        $this->dom->addChild(
1674
            $aqua,
1675
            "nViagem",
1676
            $nViagem,
1677
            true,
1678
            "Número da Viagem"
1679
        );
1680
        $this->dom->addChild(
1681
            $aqua,
1682
            "cPrtEmb",
1683
            $cPrtEmb,
1684
            true,
1685
            "Código do Porto de Embarque"
1686
        );
1687
        $this->dom->addChild(
1688
            $aqua,
1689
            "cPrtDest",
1690
            $cPrtDest,
1691
            true,
1692
            "Código do Porto de Destino"
1693
        );
1694
        $this->aqua = $aqua;
1695
        return $aqua;
1696
    }
1697
    
1698
    /**
1699
     * tagInfTermCarreg
1700
     * tag MDFe/infMDFe/infModal/Aqua/infTermCarreg
1701
     *
1702
     * @param  string $cTermCarreg
1703
     *
1704
     * @return DOMElement
1705
     */
1706
    public function taginfTermCarreg(
1707
        $cTermCarreg = ''
1708
    ) {
1709
        $infTermCarreg = $this->dom->createElement("infTermCarreg");
1710
        $this->dom->addChild(
1711
            $infTermCarreg,
1712
            "cTermCarreg",
1713
            $cTermCarreg,
1714
            true,
1715
            "Código do Terminal de Carregamento"
1716
        );
1717
        $this->aInfTermCarreg[] = $infTermCarreg;
0 ignored issues
show
Bug introduced by
The property aInfTermCarreg 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...
1718
        return $infTermCarreg;
1719
    }
1720
    /**
1721
     * tagInfTermDescarreg
1722
     * tag MDFe/infMDFe/infModal/Aqua/infTermDescarreg
1723
     *
1724
     * @param  string $cTermDescarreg
1725
     *
1726
     * @return DOMElement
1727
     */
1728
    public function taginfTermDescarreg(
1729
        $cTermDescarreg = ''
1730
    ) {
1731
        $infTermDescarreg = $this->dom->createElement("infTermDescarreg");
1732
        $this->dom->addChild(
1733
            $infTermDescarreg,
1734
            "cTermCarreg",
1735
            $cTermDescarreg,
1736
            true,
1737
            "Código do Terminal de Descarregamento"
1738
        );
1739
        $this->aInfTermDescarreg[] = $infTermDescarreg;
0 ignored issues
show
Bug introduced by
The property aInfTermDescarreg 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...
1740
        return $infTermDescarreg;
1741
    }
1742
    /**
1743
     * tagInfEmbComb
1744
     * tag MDFe/infMDFe/infModal/Aqua/infEmbComb
1745
     *
1746
     * @param  string $cEmbComb
1747
     *
1748
     * @return DOMElement
1749
     */
1750
    public function taginfEmbComb(
1751
        $cEmbComb = ''
1752
    ) {
1753
        $infEmbComb = $this->dom->createElement("infEmbComb");
1754
        $this->dom->addChild(
1755
            $infEmbComb,
1756
            "cEmbComb",
1757
            $cEmbComb,
1758
            true,
1759
            "Código da embarcação do comboio"
1760
        );
1761
        $this->aInfEmbComb[] = $infEmbComb;
0 ignored issues
show
Bug introduced by
The property aInfEmbComb 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...
1762
        return $infEmbComb;
1763
    }
1764
    
1765
    /**
1766
     * tagVeicTracao
1767
     * tag MDFe/infMDFe/infModal/rodo/veicTracao
1768
     *
1769
     * @param  string $cInt
1770
     * @param  string $placa
0 ignored issues
show
Bug introduced by
There is no parameter named $cInt. 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...
1771
     * @param  string $tara
0 ignored issues
show
Bug introduced by
There is no parameter named $placa. 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...
1772
     * @param  string $capKG
0 ignored issues
show
Bug introduced by
There is no parameter named $tara. 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...
1773
     * @param  string $capM3
0 ignored issues
show
Bug introduced by
There is no parameter named $capKG. 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...
1774
     * @param  string $tpRod
0 ignored issues
show
Bug introduced by
There is no parameter named $capM3. 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...
1775
     * @param  string $tpCar
0 ignored issues
show
Bug introduced by
There is no parameter named $tpRod. 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...
1776
     * @param  string $UF
0 ignored issues
show
Bug introduced by
There is no parameter named $tpCar. 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...
1777
     * @param  string $propRNTRC
0 ignored issues
show
Bug introduced by
There is no parameter named $UF. 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...
1778
     * @param  string $propCPF
0 ignored issues
show
Bug introduced by
There is no parameter named $propRNTRC. 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...
1779
     * @param  string $propCNPJ
0 ignored issues
show
Bug introduced by
There is no parameter named $propCPF. 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...
1780
     * @param  string $propXNome
0 ignored issues
show
Bug introduced by
There is no parameter named $propCNPJ. 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...
1781
     * @param  string $propIE
0 ignored issues
show
Bug introduced by
There is no parameter named $propXNome. 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...
1782
     * @param  string $propUF
0 ignored issues
show
Bug introduced by
There is no parameter named $propIE. 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...
1783
     * @param  string $propTpProp
0 ignored issues
show
Bug introduced by
There is no parameter named $propUF. 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...
1784
     *
0 ignored issues
show
Bug introduced by
There is no parameter named $propTpProp. 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...
1785
     * @return DOMElement
1786
     */
1787
1788
    public function tagveicTracao(stdClass $std)
1789
    {
1790
        $possible = [
1791
            'cInt',
1792
            'placa',
1793
            'RENAVAM',
1794
            'tara',
1795
            'capKG',
1796
            'capM3',
1797
            'prop',
1798
            'condutor',
1799
            'tpRod',
1800
            'tpCar',
1801
            'UF'
1802
        ];
1803
        $std = $this->equilizeParameters($std, $possible);
1804
        $veicTracao = $this->dom->createElement("veicTracao");
1805
        $this->dom->addChild(
1806
            $veicTracao,
1807
            "cInt",
1808
            $std->cInt,
1809
            false,
1810
            "Código interno do veículo"
1811
        );
1812
        $this->dom->addChild(
1813
            $veicTracao,
1814
            "placa",
1815
            $std->placa,
1816
            true,
1817
            "Placa do veículo"
1818
        );
1819
        $this->dom->addChild(
1820
            $veicTracao,
1821
            "RENAVAM",
1822
            $std->RENAVAM,
1823
            false,
1824
            "RENAVAM"
1825
        );
1826
        $this->dom->addChild(
1827
            $veicTracao,
1828
            "tara",
1829
            $std->tara,
1830
            true,
1831
            "Tara em KG"
1832
        );
1833
        $this->dom->addChild(
1834
            $veicTracao,
1835
            "capKG",
1836
            $std->capKG,
1837
            false,
1838
            "Capacidade em KG"
1839
        );
1840
        $this->dom->addChild(
1841
            $veicTracao,
1842
            "capM3",
1843
            $std->capM3,
1844
            false,
1845
            "Capacidade em M3"
1846
        );
1847 View Code Duplication
        if ($std->prop != null) {
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...
1848
            $possible = [
1849
                'CPF',
1850
                'CNPJ',
1851
                'RNTRC',
1852
                'xNome',
1853
                'IE',
1854
                'UF',
1855
                'TpProp'
1856
            ];
1857
            $stdprop = $this->equilizeParameters($std->prop, $possible);
1858
            $prop = $this->dom->createElement("prop");
1859
            $this->dom->addChild(
1860
                $prop,
1861
                "CPF",
1862
                $stdprop->CPF,
1863
                true,
1864
                "Número do CPF"
1865
            );
1866
            $this->dom->addChild(
1867
                $prop,
1868
                "CNPJ",
1869
                $stdprop->CNPJ,
1870
                true,
1871
                "Número do CNPJ"
1872
            );
1873
            $this->dom->addChild(
1874
                $prop,
1875
                "RNTRC",
1876
                $stdprop->RNTRC,
1877
                true,
1878
                "RNTRC"
1879
            );
1880
            $this->dom->addChild(
1881
                $prop,
1882
                "xNome",
1883
                $stdprop->xNome,
1884
                true,
1885
                "Razão Social"
1886
            );
1887
            $this->dom->addChild(
1888
                $prop,
1889
                "IE",
1890
                $stdprop->IE,
1891
                true,
1892
                "Inscrição Estadual"
1893
            );
1894
            $this->dom->addChild(
1895
                $prop,
1896
                "UF",
1897
                $stdprop->UF,
1898
                true,
1899
                "Unidade da Federação"
1900
            );
1901
            $this->dom->addChild(
1902
                $prop,
1903
                "TpProp",
1904
                $stdprop->TpProp,
1905
                true,
1906
                "Tipo Proprietário"
1907
            );
1908
            $this->dom->appChild($veicTracao, $prop, 'Falta tag "prop"');
1909
        }
1910
        
1911 View Code Duplication
        if ($std->condutor != null) {
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...
1912
            $possible = [
1913
                'xNome',
1914
                'CPF'
1915
            ];
1916
            $stdcondutor = $this->equilizeParameters($std->condutor, $possible);
1917
            $condutor = $this->dom->createElement("condutor");
1918
            $this->dom->addChild(
1919
                $condutor,
1920
                "xNome",
1921
                $stdcondutor->xNome,
1922
                true,
1923
                "Nome do Condutor "
1924
            );
1925
            $this->dom->addChild(
1926
                $condutor,
1927
                "CPF",
1928
                $stdcondutor->CPF,
1929
                true,
1930
                "CPF do Condutor "
1931
            );
1932
            $this->dom->appChild($veicTracao, $condutor, 'Falta tag "condutor"');
1933
        }
1934
        $this->dom->addChild(
1935
            $veicTracao,
1936
            "tpRod",
1937
            $std->tpRod,
1938
            true,
1939
            "Tipo de rodado"
1940
        );
1941
        $this->dom->addChild(
1942
            $veicTracao,
1943
            "tpCar",
1944
            $std->tpCar,
1945
            true,
1946
            "Tipo de carroceria"
1947
        );
1948
        $this->dom->addChild(
1949
            $veicTracao,
1950
            "UF",
1951
            $std->UF,
1952
            true,
1953
            "UF de licenciamento do veículo"
1954
        );
1955
1956
        $this->dom->appChild($this->rodo, $veicTracao, 'Falta tag "veicTracao"');
1957
        return $this->rodo;
1958
    }
1959
1960
    /**
1961
     * tagVeicReboque
1962
     * tag MDFe/infMDFe/infModal/rodo/VeicReboque
1963
     *
1964
     * @param string $cInt
0 ignored issues
show
Bug introduced by
There is no parameter named $cInt. 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...
1965
     * @param string $placa
0 ignored issues
show
Bug introduced by
There is no parameter named $placa. 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...
1966
     * @param string $tara
0 ignored issues
show
Bug introduced by
There is no parameter named $tara. 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...
1967
     * @param string $capKG
0 ignored issues
show
Bug introduced by
There is no parameter named $capKG. 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...
1968
     * @param string $capM3
0 ignored issues
show
Bug introduced by
There is no parameter named $capM3. 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...
1969
     * @param string $propRNTRC
0 ignored issues
show
Bug introduced by
There is no parameter named $propRNTRC. 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...
1970
     * @param string $propCPF
0 ignored issues
show
Bug introduced by
There is no parameter named $propCPF. 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...
1971
     * @param string $propCNPJ
0 ignored issues
show
Bug introduced by
There is no parameter named $propCNPJ. 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...
1972
     * @param string $propXNome
0 ignored issues
show
Bug introduced by
There is no parameter named $propXNome. 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...
1973
     * @param string $propIE
0 ignored issues
show
Bug introduced by
There is no parameter named $propIE. 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...
1974
     * @param string $propUF
0 ignored issues
show
Bug introduced by
There is no parameter named $propUF. 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...
1975
     * @param string $propTpProp
0 ignored issues
show
Bug introduced by
There is no parameter named $propTpProp. 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...
1976
     * @param string $tpCar
0 ignored issues
show
Bug introduced by
There is no parameter named $tpCar. 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...
1977
     * @param string $UF
0 ignored issues
show
Bug introduced by
There is no parameter named $UF. 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...
1978
     *
1979
     * @return DOMElement
1980
     */
1981
    public function tagveicReboque(stdClass $std)
1982
    {
1983
        $possible = [
1984
            'cInt',
1985
            'placa',
1986
            'RENAVAM',
1987
            'tara',
1988
            'capKG',
1989
            'capM3',
1990
            'prop',
1991
            'tpCar',
1992
            'UF'
1993
        ];
1994
        $std = $this->equilizeParameters($std, $possible);
1995
        $veicReboque = $this->dom->createElement("veicReboque");
1996
        $this->dom->addChild(
1997
            $veicReboque,
1998
            "cInt",
1999
            $std->cInt,
2000
            false,
2001
            "Código interno do veículo"
2002
        );
2003
        $this->dom->addChild(
2004
            $veicReboque,
2005
            "placa",
2006
            $std->placa,
2007
            true,
2008
            "Placa do veículo"
2009
        );
2010
        $this->dom->addChild(
2011
            $veicReboque,
2012
            "RENAVAM",
2013
            $std->RENAVAM,
2014
            false,
2015
            "RENAVAM"
2016
        );
2017
        $this->dom->addChild(
2018
            $veicReboque,
2019
            "tara",
2020
            $std->tara,
2021
            true,
2022
            "Tara em KG"
2023
        );
2024
        $this->dom->addChild(
2025
            $veicReboque,
2026
            "capKG",
2027
            $std->capKG,
2028
            false,
2029
            "Capacidade em KG"
2030
        );
2031
        $this->dom->addChild(
2032
            $veicReboque,
2033
            "capM3",
2034
            $std->capM3,
2035
            false,
2036
            "Capacidade em M3"
2037
        );
2038 View Code Duplication
        if ($std->prop != null) {
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...
2039
            $possible = [
2040
                'CPF',
2041
                'CNPJ',
2042
                'RNTRC',
2043
                'xNome',
2044
                'IE',
2045
                'UF',
2046
                'TpProp'
2047
            ];
2048
            $stdprop = $this->equilizeParameters($std->prop, $possible);
2049
            $prop = $this->dom->createElement("prop");
2050
            $this->dom->addChild(
2051
                $prop,
2052
                "CPF",
2053
                $stdprop->CPF,
2054
                true,
2055
                "Número do CPF"
2056
            );
2057
            $this->dom->addChild(
2058
                $prop,
2059
                "CNPJ",
2060
                $stdprop->CNPJ,
2061
                true,
2062
                "Número do CNPJ"
2063
            );
2064
            $this->dom->addChild(
2065
                $prop,
2066
                "RNTRC",
2067
                $stdprop->RNTRC,
2068
                true,
2069
                "RNTRC"
2070
            );
2071
            $this->dom->addChild(
2072
                $prop,
2073
                "xNome",
2074
                $stdprop->xNome,
2075
                true,
2076
                "Razão Social"
2077
            );
2078
            $this->dom->addChild(
2079
                $prop,
2080
                "IE",
2081
                $stdprop->IE,
2082
                true,
2083
                "Inscrição Estadual"
2084
            );
2085
            $this->dom->addChild(
2086
                $prop,
2087
                "UF",
2088
                $stdprop->UF,
2089
                true,
2090
                "Unidade da Federação"
2091
            );
2092
            $this->dom->addChild(
2093
                $prop,
2094
                "TpProp",
2095
                $stdprop->TpProp,
2096
                true,
2097
                "Tipo Proprietário"
2098
            );
2099
            $this->dom->appChild($veicReboque, $prop, 'Falta tag "prop"');
2100
        }
2101
        $this->dom->addChild(
2102
            $veicReboque,
2103
            "tpCar",
2104
            $std->tpCar,
2105
            true,
2106
            "Tipo de carroceria"
2107
        );
2108
        $this->dom->addChild(
2109
            $veicReboque,
2110
            "UF",
2111
            $std->UF,
2112
            true,
2113
            "UF de licenciamento do veículo"
2114
        );
2115
2116
        $this->dom->appChild($this->rodo, $veicReboque, 'Falta tag "veicReboque"');
2117
        return $this->rodo;
2118
    }
2119
2120
    /**
2121
     * tagcodAgPorto
2122
     * tag MDFe/infMDFe/infModal/rodo/codAgPorto
2123
     *
2124
     * @param  string codAgPorto
2125
     *
2126
     * @return DOMElement
2127
     */
2128
    public function tagcodAgPorto(stdClass $std)
2129
    {
2130
        $possible = [
2131
            'codAgPorto'
2132
        ];
2133
        $std = $this->equilizeParameters($std, $possible);
2134
        $this->dom->addChild(
2135
            $this->rodo,
2136
            "codAgPorto",
2137
            $std->codAgPorto,
2138
            false,
2139
            "Código de Agendamento no porto"
2140
        );
2141
        return $this->rodo;
2142
    }
2143
2144
    /**
2145
     * taglacRodo
2146
     * tag MDFe/infMDFe/infModal/rodo/lacRodo
2147
     *
2148
     * @param  string nLacre
2149
     *
2150
     * @return DOMElement
2151
     */
2152
    public function taglacRodo(stdClass $std)
2153
    {
2154
        $possible = [
2155
            'nLacre'
2156
        ];
2157
        $std = $this->equilizeParameters($std, $possible);
2158
        $lacRodo = $this->dom->createElement("lacRodo");
2159
        $this->dom->addChild(
2160
            $lacRodo,
2161
            "nLacre",
2162
            $std->nLacre,
2163
            false,
2164
            "Número do Lacre"
2165
        );
2166
        $this->dom->appChild($this->rodo, $lacRodo, 'Falta tag "lacRodo"');
2167
        return $this->rodo;
2168
    }
2169
2170
    /**
2171
     * buildMDFe
2172
     * Tag raiz da MDFe
2173
     * tag MDFe DOMNode
2174
     * Função chamada pelo método [ monta ]
2175
     *
2176
     * @return DOMElement
2177
     */
2178
    protected function buildMDFe()
2179
    {
2180
        if (empty($this->MDFe)) {
2181
            $this->MDFe = $this->dom->createElement("MDFe");
2182
            $this->MDFe->setAttribute("xmlns", "http://www.portalfiscal.inf.br/mdfe");
2183
        }
2184
        return $this->MDFe;
2185
    }
2186
2187
    /**
2188
     * Adiciona as tags
2189
     * infMunCarrega e infPercurso
2190
     * a tag ide
2191
     */
2192
    
2193
    protected function buildTagIde()
2194
    {
2195
        if (! empty($this->aInfMunCarrega)) {
2196
            $this->dom->addArrayChild($this->ide, $this->aInfMunCarrega);
2197
        }
2198
        if (! empty($this->aInfPercurso)) {
2199
            $this->dom->addArrayChild($this->ide, $this->aInfPercurso);
2200
        }
2201
    }
2202
    
2203
    /**
2204
     * checkMDFKey
2205
     * Remonta a chave do MDFe de 44 digitos com base em seus dados
2206
     * Isso é útil no caso da chave informada estar errada
2207
     * se a chave estiver errada a mesma é substituida
2208
     *
2209
     * @param object $dom
2210
     */
2211
    private function checkMDFKey($dom)
2212
    {
2213
        $infMDFe = $dom->getElementsByTagName("infMDFe")->item(0);
2214
        $ide = $dom->getElementsByTagName("ide")->item(0);
2215
        $emit = $dom->getElementsByTagName("emit")->item(0);
2216
        $cUF = $ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2217
        $dhEmi = $ide->getElementsByTagName('dhEmi')->item(0)->nodeValue;
2218
        $cnpj = $emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2219
        $mod = $ide->getElementsByTagName('mod')->item(0)->nodeValue;
2220
        $serie = $ide->getElementsByTagName('serie')->item(0)->nodeValue;
2221
        $nNF = $ide->getElementsByTagName('nMDF')->item(0)->nodeValue;
2222
        $tpEmis = $ide->getElementsByTagName('tpEmis')->item(0)->nodeValue;
2223
        $cNF = $ide->getElementsByTagName('cMDF')->item(0)->nodeValue;
2224
        $chave = str_replace('MDFe', '', $infMDFe->getAttribute("Id"));
2225
        $dt = new DateTime($dhEmi);
2226
        $chaveMontada = Keys::build(
2227
            $cUF,
2228
            $dt->format('y'),
2229
            $dt->format('m'),
2230
            $cnpj,
2231
            $mod,
2232
            $serie,
2233
            $nNF,
2234
            $tpEmis,
2235
            $cNF
2236
        );
2237
2238
        //caso a chave contida na NFe esteja errada
2239
        //substituir a chave
2240
        if ($chaveMontada != $chave) {
2241
            $ide->getElementsByTagName('cDV')->item(0)->nodeValue = substr($chaveMontada, -1);
2242
            $infMDFe = $dom->getElementsByTagName("infMDFe")->item(0);
2243
            $infMDFe->setAttribute("Id", "MDFe" . $chaveMontada);
2244
            $infMDFe->setAttribute("versao", $this->versao);
2245
            $this->chMDFe = $chaveMontada;
2246
        }
2247
    }
2248
2249
    /**
2250
     * Includes missing or unsupported properties in stdClass
2251
     * Replace all unsuported chars
2252
     * @param stdClass $std
2253
     * @param array $possible
2254
     * @return stdClass
2255
     */
2256
    protected function equilizeParameters(stdClass $std, $possible)
2257
    {
2258
        $arr = get_object_vars($std);
2259
        foreach ($possible as $key) {
2260
            if (!array_key_exists($key, $arr)) {
2261
                $std->$key = null;
2262
            } else {
2263
                if (is_string($std->$key)) {
2264
                    $std->$key = trim(Strings::replaceUnacceptableCharacters($std->$key));
2265
                    if ($this->replaceAccentedChars) {
2266
                        $std->$key = Strings::toASCII($std->$key);
2267
                    }
2268
                }
2269
            }
2270
        }
2271
        return $std;
2272
    }
2273
}
2274