Completed
Pull Request — master (#86)
by
unknown
13:43
created

Make::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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