Passed
Push — master ( 557b8c...261827 )
by
unknown
01:08 queued 12s
created

Make::getErrors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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    Cleiton Perin <cperin20 at gmail dot com>
19
 */
20
21
use DOMElement;
22
use NFePHP\Common\DOMImproved as Dom;
23
use NFePHP\Common\Keys;
24
use NFePHP\Common\Strings;
25
use RuntimeException;
26
use stdClass;
27
28
class Make
29
{
30
    /**
31
     * @var array
32
     */
33
    public $errors = [];
34
    /**
35
     * versao
36
     * numero da versão do xml da MDFe
37
     *
38
     * @var string
39
     */
40
    public $versao = '3.00';
41
    /**
42
     * mod
43
     * modelo da MDFe 58
44
     *
45
     * @var integer
46
     */
47
    public $mod = '58';
48
    /**
49
     * chave da MDFe
50
     *
51
     * @var string
52
     */
53
    public $chMDFe = '';
54
55
    //propriedades privadas utilizadas internamente pela classe
56
    /**
57
     * @type string|\DOMNode
58
     */
59
    private $MDFe = '';
60
    /**
61
     * @type string|\DOMNode
62
     */
63
    private $infMDFe = '';
64
    /**
65
     * @type string|\DOMNode
66
     */
67
    private $ide = '';
68
    /**
69
     * @type string|\DOMNode
70
     */
71
    private $emit = '';
72
    /**
73
     * @type string|\DOMNode
74
     */
75
    private $infANTT = '';
76
    /**
77
     * @type string|\DOMNode
78
     */
79
    private $enderEmit = '';
80
    /**
81
     * @type string|\DOMNode
82
     */
83
    private $infModal = '';
84
    /**
85
     * @type string|\DOMNode
86
     */
87
    private $tot = '';
88
    /**
89
     * @type string|\DOMNode
90
     */
91
    private $seg = [];
92
    /**
93
     * @type string|\DOMNode
94
     */
95
    private $infMunDescarga = [];
96
    /**
97
     * @type string|\DOMNode
98
     */
99
    private $veicReboque = [];
100
    /**
101
     * @type string|\DOMNode
102
     */
103
    private $infNFe = [];
104
    /**
105
     * @type string|\DOMNode
106
     */
107
    private $infCTe = [];
108
    /**
109
     * @type string|\DOMNode
110
     */
111
    private $infMDFeTransp = [];
112
    /**
113
     * @type string|\DOMNode
114
     */
115
    private $infContratante = [];
116
    /**
117
     * @type string|\DOMNode
118
     */
119
    private $autXML = [];
120
    /**
121
     * @type string|\DOMNode
122
     */
123
    private $infCIOT = [];
124
    /**
125
     * @type string|\DOMNode
126
     */
127
    private $disp = [];
128
    /**
129
     * @type string|\DOMNode
130
     */
131
    private $infMunCarrega = [];
132
    /**
133
     * @type string|\DOMNode
134
     */
135
    private $infPercurso = [];
136
    /**
137
     * @type string|\DOMNode
138
     */
139
    private $lacRodo = [];
140
    /**
141
     * @type string|\DOMNode
142
     */
143
    private $vag = [];
144
    /**
145
     * @type string|\DOMNode
146
     */
147
    private $infAdic = '';
148
    /**
149
     * @type string|\DOMNode
150
     */
151
    private $rodo = '';
152
    /**
153
     * @type string|\DOMNode
154
     */
155
    private $ferrov = '';
156
    /**
157
     * @type string|\DOMNode
158
     */
159
    private $infDoc = '';
160
    /**
161
     * @type string|\DOMNode
162
     */
163
    private $valePed = '';
164
    /**
165
     * @type string|\DOMNode
166
     */
167
    private $veicTracao = '';
168
    /**
169
     * @type string|\DOMNode
170
     */
171
    private $infUnidTransp = '';
172
    /**
173
     * @type string|\DOMNode
174
     */
175
    private $aereo = '';
176
    /**
177
     * @type string|\DOMNode
178
     */
179
    private $trem = '';
180
    /**
181
     * @type string|\DOMNode
182
     */
183
    private $aquav = '';
184
    /**
185
     * @type array
186
     */
187
    private $infTermCarreg = [];
188
    /**
189
     * @type array
190
     */
191
    private $infTermDescarreg = [];
192
    /**
193
     * @type array
194
     */
195
    private $infEmbComb = [];
196
    /**
197
     * @type array
198
     */
199
    private $infUnidCargaVazia = [];
200
    /**
201
     * @type array
202
     */
203
    private $infUnidTranspVazia = [];
204
    /**
205
     * @var boolean
206
     */
207
    protected $replaceAccentedChars = false;
208
209
    /**
210
     * Função construtora cria um objeto DOMDocument
211
     * que será carregado com o documento fiscal
212
     */
213
    public function __construct()
214
    {
215
        $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...
216
        $this->dom->preserveWhiteSpace = false;
217
        $this->dom->formatOutput = false;
218
    }
219
220
    /**
221
     * Retorns the xml
222
     *
223
     * @return xml
224
     */
225
    public function getXML()
226
    {
227
        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...
228
            $this->montaMDFe();
229
        }
230
        return $this->xml;
231
    }
232
233
    /**
234
     * Retorns the key number of NFe (44 digits)
235
     *
236
     * @return string
237
     */
238
    public function getChave()
239
    {
240
        return $this->chMDFe;
241
    }
242
243
    /**
244
     * Returns the model of MDFe
245
     *
246
     * @return int
247
     */
248
    public function getModelo()
249
    {
250
        return $this->mod;
251
    }
252
253
    /**
254
     * Set character convertion to ASCII only ou not
255
     * @param bool $option
256
     */
257
    public function setOnlyAscii($option = false)
258
    {
259
        $this->replaceAccentedChars = $option;
260
    }
261
262
    /**
263
     * Call method of xml assembly. For compatibility only.
264
     *
265
     * @return boolean
266
     */
267
    public function montaMDFe()
268
    {
269
        return $this->monta();
270
    }
271
272
    /**
273
     * MDFe xml mount method
274
     * this function returns TRUE on success or FALSE on error
275
     * The xml of the MDFe must be retrieved by the getXML() function or
276
     * directly by the public property $xml
277
     *
278
     * @return boolean
279
     */
280
    public function monta()
281
    {
282
        $this->errors = $this->dom->errors;
283
        //cria a tag raiz da MDFe
284
        $this->buildMDFe();
285
        $this->buildInfModal();
286
        $this->infMDFe = $this->dom->createElement("infMDFe");
287
        $this->buildIde();
288
        $this->dom->appChild($this->emit, $this->enderEmit, 'Falta tag "enderEmit"');
289
        $this->dom->appChild($this->infMDFe, $this->emit, 'Falta tag "emit"');
290
        if ($this->rodo) {
291
            if ($this->infANTT) {
292
                if ($this->infCIOT) {
293
                    $this->dom->addArrayChild($this->infANTT, $this->infCIOT, 'Falta tag "infCIOT"');
294
                }
295
                if ($this->valePed) {
296
                    $this->dom->appChild($this->infANTT, $this->valePed, 'Falta tag "valePed"');
297
                    if ($this->disp) {
298
                        $this->dom->addArrayChild($this->valePed, $this->disp, 'Falta tag "disp"');
299
                    }
300
                }
301
                if ($this->infContratante) {
302
                    $this->dom->addArrayChild($this->infANTT, $this->infContratante, 'Falta tag "infContratante"');
303
                }
304
                $this->dom->appChild($this->rodo, $this->infANTT, 'Falta tag "infANTT"');
305
            }
306
            if ($this->veicTracao) {
307
                $this->dom->appChild($this->rodo, $this->veicTracao, 'Falta tag "rodo"');
308
            }
309
            if ($this->veicReboque) {
310
                $this->dom->addArrayChild($this->rodo, $this->veicReboque, 'Falta tag "veicReboque"');
311
            }
312
            if ($this->lacRodo) {
313
                $this->dom->addArrayChild($this->rodo, $this->lacRodo, 'Falta tag "lacRodo"');
314
            }
315
            $this->dom->appChild($this->infModal, $this->rodo, 'Falta tag "infModal"');
316
        }
317
        if ($this->aereo) {
318
            $this->dom->appChild($this->infModal, $this->aereo, 'Falta tag "aereo"');
319
        }
320
        if ($this->ferrov) {
321
            if ($this->trem) {
322
                $this->dom->appChild($this->ferrov, $this->trem, 'Falta tag "ferrov"');
323
            }
324
            if ($this->vag) {
325
                $this->dom->addArrayChild($this->ferrov, $this->vag, 'Falta tag "vag"');
326
            }
327
            $this->dom->appChild($this->infModal, $this->ferrov, 'Falta tag "ferrov"');
328
        }
329
        if ($this->aquav) {
330
            foreach ($this->infTermCarreg as $termCarreg) {
331
                $this->dom->appChild($this->aquav, $termCarreg, 'Falta tag "aquav"');
332
            }
333
            foreach ($this->infTermDescarreg as $termDescarreg) {
334
                $this->dom->appChild($this->aquav, $termDescarreg, 'Falta tag "aquav"');
335
            }
336
            foreach ($this->infEmbComb as $embComb) {
337
                $this->dom->appChild($this->aquav, $embComb, 'Falta tag "aquav"');
338
            }
339
            foreach ($this->infUnidCargaVazia as $unidCargaVazia) {
340
                $this->dom->appChild($this->aquav, $unidCargaVazia, 'Falta tag "aquav"');
341
            }
342
            foreach ($this->infUnidTranspVazia as $unidTranspVazia) {
343
                $this->dom->appChild($this->aquav, $unidTranspVazia, 'Falta tag "aquav"');
344
            }
345
            $this->dom->appChild($this->infModal, $this->aquav, 'Falta tag "aquav"');
346
        }
347
        $this->dom->appChild($this->infMDFe, $this->infModal, 'Falta tag "infModal"');
348
        if ($this->infDoc) {
349
            $this->dom->appChild($this->infMDFe, $this->infDoc, 'Falta tag "infDoc"');
350
            if ($this->infMunDescarga) {
351
                foreach ($this->infMunDescarga as $key => $value) {
0 ignored issues
show
Bug introduced by
The expression $this->infMunDescarga 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...
352
                    $this->dom->appChild($this->infDoc, $value, 'Falta tag "infMunDescarga"');
353
                    if (isset($this->infCTe[$key])) {
354
                        $this->dom->addArrayChild($value, $this->infCTe[$key], 'Falta tag "infCTe"');
355
                    }
356
                    if (isset($this->infNFe[$key])) {
357
                        $this->dom->addArrayChild($value, $this->infNFe[$key], 'Falta tag "infNFe"');
358
                    }
359
                    if (isset($this->infMDFeTransp[$key])) {
360
                        $this->dom->addArrayChild($value, $this->infMDFeTransp[$key], 'Falta tag "infMDFeTransp"');
361
                    }
362
                }
363
            }
364
        }
365
        if (!empty($this->seg)) {
366
            $this->dom->addArrayChild($this->infMDFe, $this->seg, 'Falta tag "seg"');
367
        }
368
        $this->dom->appChild($this->infMDFe, $this->tot, 'Falta tag "tot"');
369
        if (!empty($this->lacres)) {
370
            foreach ($this->lacres as $lacres) {
0 ignored issues
show
Bug introduced by
The property lacres 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...
371
                $this->dom->appChild($this->infMDFe, $lacres, 'Falta tag "lacres"');
372
            }
373
        }
374
        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...
375
            $this->dom->appChild($this->infMDFe, $autXML, 'Falta tag "infMDFe"');
376
        }
377
        if (!empty($this->infAdic)) {
378
            $this->dom->appChild($this->infMDFe, $this->infAdic, 'Falta tag "infAdic"');
379
        }
380
        $this->dom->appChild($this->MDFe, $this->infMDFe, 'Falta tag "infMDFe"');
381
        $this->dom->appendChild($this->MDFe);
382
        // testa da chave
383
        $this->checkMDFKey($this->dom);
384
        $this->xml = $this->dom->saveXML();
385
        if (count($this->errors) > 0) {
386
            throw new RuntimeException('Existem erros nas tags. Obtenha os erros com getErrors().');
387
        }
388
        return true;
389
    }
390
391
    /**
392
     * Informações de identificação da MDFe
393
     * tag MDFe/infMDFe/ide
394
     *
395
     * @param  stdClass $std
396
     * @return DOMElement
397
     */
398
    public function tagide(stdClass $std)
399
    {
400
401
        $possible = [
402
            'cUF',
403
            'tpAmb',
404
            'tpEmit',
405
            'tpTransp',
406
            'mod',
407
            'serie',
408
            'nMDF',
409
            'cMDF',
410
            'cDV',
411
            'modal',
412
            'dhEmi',
413
            'tpEmis',
414
            'procEmi',
415
            'verProc',
416
            'UFIni',
417
            'UFFim',
418
            'dhIniViagem',
419
            'indCanalVerde',
420
            'indCarregaPosterior'
421
        ];
422
423
        $std = $this->equilizeParameters($std, $possible);
424
425
        $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...
426
        $identificador = '[4] <ide> - ';
427
        $ide = $this->dom->createElement("ide");
428
        $this->dom->addChild(
429
            $ide,
430
            "cUF",
431
            $std->cUF,
432
            true,
433
            $identificador . "Código da UF do emitente do Documento Fiscal"
434
        );
435
        $this->dom->addChild(
436
            $ide,
437
            "tpAmb",
438
            $std->tpAmb,
439
            true,
440
            $identificador . "Identificação do Ambiente"
441
        );
442
        $this->dom->addChild(
443
            $ide,
444
            "tpEmit",
445
            $std->tpEmit,
446
            true,
447
            $identificador . "Indicador da tipo de emitente"
448
        );
449
        $this->dom->addChild(
450
            $ide,
451
            "tpTransp",
452
            $std->tpTransp,
453
            false,
454
            $identificador . "Tipo do Transportador"
455
        );
456
        $this->dom->addChild(
457
            $ide,
458
            "mod",
459
            $std->mod,
460
            true,
461
            $identificador . "Código do Modelo do Documento Fiscal"
462
        );
463
        $this->dom->addChild(
464
            $ide,
465
            "serie",
466
            $std->serie,
467
            true,
468
            $identificador . "Série do Documento Fiscal"
469
        );
470
        $this->dom->addChild(
471
            $ide,
472
            "nMDF",
473
            $std->nMDF,
474
            true,
475
            $identificador . "Número do Documento Fiscal"
476
        );
477
        $this->dom->addChild(
478
            $ide,
479
            "cMDF",
480
            str_pad($std->cMDF, 8, '0', STR_PAD_LEFT),
481
            true,
482
            $identificador . "Código do numérico do MDF"
483
        );
484
        $this->dom->addChild(
485
            $ide,
486
            "cDV",
487
            $std->cDV,
488
            true,
489
            $identificador . "Dígito Verificador da Chave de Acesso da NF-e"
490
        );
491
        $this->dom->addChild(
492
            $ide,
493
            "modal",
494
            $std->modal,
495
            true,
496
            $identificador . "Modalidade de transporte"
497
        );
498
        $this->dom->addChild(
499
            $ide,
500
            "dhEmi",
501
            $std->dhEmi,
502
            true,
503
            $identificador . "Data e hora de emissão do Documento Fiscal"
504
        );
505
        $this->dom->addChild(
506
            $ide,
507
            "tpEmis",
508
            $std->tpEmis,
509
            true,
510
            $identificador . "Tipo de Emissão do Documento Fiscal"
511
        );
512
        $this->dom->addChild(
513
            $ide,
514
            "procEmi",
515
            $std->procEmi,
516
            true,
517
            $identificador . "Processo de emissão"
518
        );
519
        $this->dom->addChild(
520
            $ide,
521
            "verProc",
522
            $std->verProc,
523
            true,
524
            $identificador . "Versão do Processo de emissão"
525
        );
526
        $this->dom->addChild(
527
            $ide,
528
            "UFIni",
529
            $std->UFIni,
530
            true,
531
            $identificador . "Sigla da UF do Carregamento"
532
        );
533
        $this->dom->addChild(
534
            $ide,
535
            "UFFim",
536
            $std->UFFim,
537
            true,
538
            $identificador . "Sigla da UF do Descarregamento"
539
        );
540
        $this->dom->addChild(
541
            $ide,
542
            "dhIniViagem",
543
            $std->dhIniViagem,
544
            false,
545
            $identificador . "Data e hora previstos de início da viagem"
546
        );
547
        $this->dom->addChild(
548
            $ide,
549
            "indCanalVerde",
550
            $std->indCanalVerde,
551
            false,
552
            $identificador . "Indicador de participação do Canal Verde"
553
        );
554
        $this->dom->addChild(
555
            $ide,
556
            "indCarregaPosterior",
557
            $std->indCarregaPosterior,
558
            false,
559
            $identificador . "Indicador de MDF-e com inclusão da Carga posterior a emissão por evento de inclusão de DF-e"
560
        );
561
562
        $this->mod = $std->mod;
563
        $this->ide = $ide;
564
        return $ide;
565
    }
566
567
    /**
568
     * taginfMunCarrega
569
     *
570
     * tag MDFe/infMDFe/ide/infMunCarrega
571
     *
572
     * @param  stdClass $std
573
     * @return DOMElement
574
     */
575
    public function taginfMunCarrega(stdClass $std)
576
    {
577
        $possible = [
578
            'cMunCarrega',
579
            'xMunCarrega'
580
        ];
581
582
        $std = $this->equilizeParameters($std, $possible);
583
        $infMunCarrega = $this->dom->createElement("infMunCarrega");
584
        $this->dom->addChild(
585
            $infMunCarrega,
586
            "cMunCarrega",
587
            $std->cMunCarrega,
588
            true,
589
            "Código do Município de Carregamento"
590
        );
591
        $this->dom->addChild(
592
            $infMunCarrega,
593
            "xMunCarrega",
594
            $std->xMunCarrega,
595
            true,
596
            "Nome do Município de Carregamento"
597
        );
598
        $this->infMunCarrega[] = $infMunCarrega;
599
        return $infMunCarrega;
600
    }
601
602
    /**
603
     * tagInfPercurso
604
     *
605
     * tag MDFe/infMDFe/ide/infPercurso
606
     *
607
     * @param  stdClass $std
608
     * @return DOMElement
609
     */
610
    public function taginfPercurso(stdClass $std)
611
    {
612
        $possible = [
613
            'UFPer'
614
        ];
615
616
        $std = $this->equilizeParameters($std, $possible);
617
        $infPercurso = $this->dom->createElement("infPercurso");
618
        $this->dom->addChild(
619
            $infPercurso,
620
            "UFPer",
621
            $std->UFPer,
622
            true,
623
            "Sigla das Unidades da Federação do percurso"
624
        );
625
        $this->infPercurso[] = $infPercurso;
626
        return $infPercurso;
627
    }
628
629
    /**
630
     * tagemit
631
     * Identificação do emitente da MDFe
632
     * tag MDFe/infMDFe/emit
633
     *
634
     * @param  stdClass $std
635
     * @return DOMElement
636
     */
637
    public function tagemit(stdClass $std)
638
    {
639
        $possible = [
640
            'CNPJ',
641
            'CPF',
642
            'IE',
643
            'xNome',
644
            'xFant'
645
        ];
646
        $std = $this->equilizeParameters($std, $possible);
647
648
        $identificador = '[25] <emit> - ';
649
        $this->emit = $this->dom->createElement("emit");
650
        if ($std->CPF) {
651
            $this->dom->addChild(
652
                $this->emit,
653
                "CPF",
654
                $std->CPF,
655
                true,
656
                $identificador . "CPF do emitente"
657
            );
658
        } else {
659
            $this->dom->addChild(
660
                $this->emit,
661
                "CNPJ",
662
                $std->CNPJ,
663
                true,
664
                $identificador . "CNPJ do emitente"
665
            );
666
        }
667
        $this->dom->addChild(
668
            $this->emit,
669
            "IE",
670
            $std->IE,
671
            false,
672
            $identificador . "Inscrição Estadual do emitente"
673
        );
674
        $this->dom->addChild(
675
            $this->emit,
676
            "xNome",
677
            $std->xNome,
678
            true,
679
            $identificador . "Razão Social ou Nome do emitente"
680
        );
681
        $this->dom->addChild(
682
            $this->emit,
683
            "xFant",
684
            $std->xFant,
685
            false,
686
            $identificador . "Nome fantasia do emitente"
687
        );
688
        return $this->emit;
689
    }
690
691
    /**
692
     * tagenderEmit
693
     * Endereço do emitente [30] pai [25]
694
     * tag MDFe/infMDFe/emit/endEmit
695
     *
696
     * @param  stdClass $std
697
     * @return DOMElement
698
     */
699
    public function tagenderEmit(stdClass $std)
700
    {
701
        $possible = [
702
            'xLgr',
703
            'nro',
704
            'xCpl',
705
            'xBairro',
706
            'cMun',
707
            'xMun',
708
            'CEP',
709
            'UF',
710
            'fone',
711
            'email'
712
        ];
713
        $std = $this->equilizeParameters($std, $possible);
714
715
        $identificador = '[30] <enderEmit> - ';
716
        $this->enderEmit = $this->dom->createElement("enderEmit");
717
718
        $this->dom->addChild(
719
            $this->enderEmit,
720
            "xLgr",
721
            $std->xLgr,
722
            true,
723
            $identificador . "Logradouro do Endereço do emitente"
724
        );
725
        $this->dom->addChild(
726
            $this->enderEmit,
727
            "nro",
728
            $std->nro,
729
            true,
730
            $identificador . "Número do Endereço do emitente"
731
        );
732
        $this->dom->addChild(
733
            $this->enderEmit,
734
            "xCpl",
735
            $std->xCpl,
736
            false,
737
            $identificador . "Complemento do Endereço do emitente"
738
        );
739
        $this->dom->addChild(
740
            $this->enderEmit,
741
            "xBairro",
742
            $std->xBairro,
743
            true,
744
            $identificador . "Bairro do Endereço do emitente"
745
        );
746
        $this->dom->addChild(
747
            $this->enderEmit,
748
            "cMun",
749
            $std->cMun,
750
            true,
751
            $identificador . "Código do município do Endereço do emitente"
752
        );
753
        $this->dom->addChild(
754
            $this->enderEmit,
755
            "xMun",
756
            $std->xMun,
757
            true,
758
            $identificador . "Nome do município do Endereço do emitente"
759
        );
760
        $this->dom->addChild(
761
            $this->enderEmit,
762
            "CEP",
763
            $std->CEP,
764
            true,
765
            $identificador . "Código do CEP do Endereço do emitente"
766
        );
767
        $this->dom->addChild(
768
            $this->enderEmit,
769
            "UF",
770
            $std->UF,
771
            true,
772
            $identificador . "Sigla da UF do Endereço do emitente"
773
        );
774
        $this->dom->addChild(
775
            $this->enderEmit,
776
            "fone",
777
            $std->fone,
778
            false,
779
            $identificador . "Número de telefone do emitente"
780
        );
781
        $this->dom->addChild(
782
            $this->enderEmit,
783
            "email",
784
            $std->email,
785
            false,
786
            $identificador . "Endereço de email do emitente"
787
        );
788
        return $this->enderEmit;
789
    }
790
791
    /**
792
     * tagrodo
793
     * tag MDFe/infMDFe/infModal/rodo
794
     *
795
     * @return DOMElement
796
     */
797
    private function tagrodo()
798
    {
799
        $this->rodo = $this->dom->createElement("rodo");
800
        return $this->rodo;
801
    }
802
803
    /**
804
     * tagferrov
805
     * tag MDFe/infMDFe/infModal/ferrov
806
     *
807
     * @return DOMElement
808
     */
809
    private function tagferrov()
810
    {
811
        if (empty($this->ferrov)) {
812
            $this->ferrov = $this->dom->createElement("ferrov");
813
        }
814
        return $this->ferrov;
815
    }
816
817
    /**
818
     * tagrodo
819
     * tag MDFe/infMDFe/infModal/rodo
820
     *
821
     * @return DOMElement
822
     */
823
    private function taginfDoc()
824
    {
825
        if (empty($this->infDoc)) {
826
            $this->infDoc = $this->dom->createElement("infDoc");
827
        }
828
        return $this->infDoc;
829
    }
830
831
    /**
832
     * valePed
833
     * tag MDFe/infMDFe/infModal/rodo/infANTT/valePed
834
     *
835
     * @return DOMElement
836
     */
837
    private function tagvalePed()
838
    {
839
        if (empty($this->valePed)) {
840
            $this->valePed = $this->dom->createElement("valePed");
841
        }
842
        return $this->valePed;
843
    }
844
845
    /**
846
     * infANTT
847
     * tag MDFe/infMDFe/infModal/rodo/infANTT
848
     *
849
     * @return DOMElement
850
     */
851
    public function taginfANTT(stdClass $std)
852
    {
853
        $possible = [
854
            'RNTRC'
855
        ];
856
        $std = $this->equilizeParameters($std, $possible);
857
        $identificador = '[2] <infANTT> - ';
858
        $infANTT = $this->dom->createElement("infANTT");
859
        $this->dom->addChild(
860
            $infANTT,
861
            "RNTRC",
862
            $std->RNTRC,
863
            false,
864
            $identificador . "Registro Nacional de Transportadores Rodoviários de Carga"
865
        );
866
        $this->infANTT = $infANTT;
867
        return $infANTT;
868
    }
869
870
    /**
871
     * disp
872
     * tag MDFe/infMDFe/infModal/rodo/infANTT/disp
873
     *
874
     * @return DOMElement
875
     */
876
    public function tagdisp(stdClass $std)
877
    {
878
        $possible = [
879
            'CNPJForn',
880
            'CNPJPg',
881
            'CPFPg',
882
            'nCompra',
883
            'vValePed'
884
        ];
885
        $this->tagvalePed();
886
        $std = $this->equilizeParameters($std, $possible);
887
        $identificador = '[4] <disp> - ';
888
        $disp = $this->dom->createElement("disp");
889
        $this->dom->addChild(
890
            $disp,
891
            "CNPJForn",
892
            $std->CNPJForn,
893
            false,
894
            $identificador . "CNPJ da empresa fornecedora do ValePedágio"
895
        );
896
        $this->dom->addChild(
897
            $disp,
898
            "CNPJPg",
899
            $std->CNPJPg,
900
            false,
901
            $identificador . "CNPJ do responsável pelo pagamento do Vale-Pedágio"
902
        );
903
        $this->dom->addChild(
904
            $disp,
905
            "CPFPg",
906
            $std->CPFPg,
907
            false,
908
            $identificador . "CPF do responsável pelo pagamento do Vale-Pedágio"
909
        );
910
        $this->dom->addChild(
911
            $disp,
912
            "nCompra",
913
            $std->nCompra,
914
            false,
915
            $identificador . "Número do comprovante de compra"
916
        );
917
        $this->dom->addChild(
918
            $disp,
919
            "vValePed",
920
            $std->vValePed,
921
            false,
922
            $identificador . "Valor do Vale-Pedagio"
923
        );
924
        $this->disp[] = $disp;
925
        return $disp;
926
    }
927
928
    /**
929
     * infContratante
930
     * tag MDFe/infMDFe/infModal/rodo/infANTT/infContratante
931
     *
932
     * @return DOMElement
933
     */
934
    public function taginfContratante(stdClass $std)
935
    {
936
        $possible = [
937
            'CPF',
938
            'CNPJ'
939
        ];
940
        $std = $this->equilizeParameters($std, $possible);
941
        $identificador = '[4] <infContratante> - ';
942
        $infContratante = $this->dom->createElement("infContratante");
943
        if ($std->CPF) {
944
            $this->dom->addChild(
945
                $infContratante,
946
                "CPF",
947
                $std->CPF,
948
                true,
949
                $identificador . "Número do CPF do contratente do serviço"
950
            );
951
        } else {
952
            $this->dom->addChild(
953
                $infContratante,
954
                "CNPJ",
955
                $std->CNPJ,
956
                true,
957
                $identificador . "Número do CNPJ do contratente do serviço"
958
            );
959
        }
960
        $this->infContratante[] = $infContratante;
961
        return $infContratante;
962
    }
963
964
    /**
965
     * infANTT
966
     * tag MDFe/infMDFe/infModal/rodo/infANTT/infCIOT
967
     *
968
     * @return DOMElement
969
     */
970
    public function taginfCIOT(stdClass $std)
971
    {
972
        $possible = [
973
            'CIOT',
974
            'CPF',
975
            'CNPJ'
976
        ];
977
        $std = $this->equilizeParameters($std, $possible);
978
        $identificador = '[4] <infCIOT> - ';
979
        $infCIOT = $this->dom->createElement("infCIOT");
980
        $this->dom->addChild(
981
            $infCIOT,
982
            "CIOT",
983
            $std->CIOT,
984
            true,
985
            $identificador . "Código Identificador da Operação de Transporte"
986
        );
987
        if ($std->CPF) {
988
            $this->dom->addChild(
989
                $infCIOT,
990
                "CPF",
991
                $std->CPF,
992
                true,
993
                $identificador . "Número do CPF responsável pela geração do CIOT"
994
            );
995
        } else {
996
            $this->dom->addChild(
997
                $infCIOT,
998
                "CNPJ",
999
                $std->CNPJ,
1000
                true,
1001
                $identificador . "Número do CNPJ responsável pela geração do CIOT"
1002
            );
1003
        }
1004
        $this->infCIOT[] = $infCIOT;
1005
        return $infCIOT;
1006
    }
1007
1008
    /**
1009
     * tagInfMunDescarga
1010
     * tag MDFe/infMDFe/infDoc/infMunDescarga
1011
     *
1012
     * @param  stdClass $std
1013
     * @return DOMElement
1014
     */
1015
    public function taginfMunDescarga(stdClass $std)
1016
    {
1017
        $possible = [
1018
            'cMunDescarga',
1019
            'xMunDescarga',
1020
            'nItem'
1021
        ];
1022
        $this->taginfDoc();
1023
        $std = $this->equilizeParameters($std, $possible);
1024
        $identificador = '[4] <infMunDescarga> - ';
1025
        $infMunDescarga = $this->dom->createElement("infMunDescarga");
1026
        $this->dom->addChild(
1027
            $infMunDescarga,
1028
            "cMunDescarga",
1029
            $std->cMunDescarga,
1030
            true,
1031
            $identificador . "Código do Município de Descarga"
1032
        );
1033
        $this->dom->addChild(
1034
            $infMunDescarga,
1035
            "xMunDescarga",
1036
            $std->xMunDescarga,
1037
            true,
1038
            $identificador . "Nome do Município de Descarga"
1039
        );
1040
        $this->infMunDescarga[$std->nItem] = $infMunDescarga;
1041
        return $infMunDescarga;
1042
    }
1043
1044
    /**
1045
     * taginfCTe
1046
     * tag MDFe/infMDFe/infDoc/infMunDescarga/infCTe
1047
     *
1048
     * @param  stdClass $std
1049
     * @return DOMElement
1050
     */
1051
    public function taginfCTe(stdClass $std)
1052
    {
1053
        $possible = [
1054
            'chCTe',
1055
            'SegCodBarra',
1056
            'indReentrega',
1057
            'infEntregaParcial',
1058
            'infUnidTransp',
1059
            'peri',
1060
            'nItem'
1061
        ];
1062
        $std = $this->equilizeParameters($std, $possible);
1063
        $infCTe = $this->dom->createElement("infCTe");
1064
        $identificador = '[4] <infCTe> - ';
1065
        $this->dom->addChild(
1066
            $infCTe,
1067
            "chCTe",
1068
            $std->chCTe,
1069
            true,
1070
            $identificador . "Chave de Acesso CTe"
1071
        );
1072
        $this->dom->addChild(
1073
            $infCTe,
1074
            "SegCodBarra",
1075
            $std->SegCodBarra,
1076
            false,
1077
            $identificador . "Segundo código de barras do CTe"
1078
        );
1079
        $this->dom->addChild(
1080
            $infCTe,
1081
            "indReentrega",
1082
            $std->indReentrega,
1083
            false,
1084
            $identificador . "Indicador de Reentrega"
1085
        );
1086
        if ($std->infUnidTransp) {
1087
            foreach ($std->infUnidTransp as $value) {
1088
                $this->dom->appChild($infCTe, $this->taginfUnidTransp($value), 'Falta tag "infUnidTransp"');
1089
            }
1090
        }
1091
        if ($std->peri) {
1092
            foreach ($std->peri as $value) {
1093
                $this->dom->appChild($infCTe, $this->tagperi($value), 'Falta tag "peri"');
1094
            }
1095
        }
1096
        if ($std->infEntregaParcial != null) {
1097
            $possible = [
1098
                'qtdTotal',
1099
                'qtdParcial'
1100
            ];
1101
            $stdinfEntregaParcial = $this->equilizeParameters($std->infEntregaParcial, $possible);
1102
            $identificadorparcial = '[4] <infEntregaParcial> - ';
1103
            $infEntregaParcial = $this->dom->createElement("infEntregaParcial");
1104
            $this->dom->addChild(
1105
                $infEntregaParcial,
1106
                "qtdTotal",
1107
                $stdinfEntregaParcial->qtdTotal,
1108
                true,
1109
                $identificadorparcial . "Quantidade total de volumes"
1110
            );
1111
            $this->dom->addChild(
1112
                $infEntregaParcial,
1113
                "qtdParcial",
1114
                $stdinfEntregaParcial->qtdParcial,
1115
                true,
1116
                $identificadorparcial . "Quantidade de volumes enviados no MDF-e"
1117
            );
1118
            $this->dom->appChild($infCTe, $infEntregaParcial, 'Falta tag "infCTe"');
1119
        }
1120
        $this->infCTe[$std->nItem][] = $infCTe;
1121
        return $infCTe;
1122
    }
1123
1124
    /**
1125
     * tagperi
1126
     * tag MDFe/infMDFe/infDoc/infMunDescarga/(infCTe/infNFe)/peri
1127
     *
1128
     * @param  stdClass $std
1129
     * @return DOMElement
1130
     */
1131
    private function tagperi(stdClass $std)
1132
    {
1133
        $possible = [
1134
            'nONU',
1135
            'xNomeAE',
1136
            'xClaRisco',
1137
            'grEmb',
1138
            'qTotProd',
1139
            'qVolTipo'
1140
        ];
1141
        $std = $this->equilizeParameters($std, $possible);
1142
        $peri = $this->dom->createElement("peri");
1143
        $this->dom->addChild(
1144
            $peri,
1145
            "nONU",
1146
            $std->nONU,
1147
            true,
1148
            "Número ONU/UN"
1149
        );
1150
        $this->dom->addChild(
1151
            $peri,
1152
            "xNomeAE",
1153
            $std->xNomeAE,
1154
            true,
1155
            "Nome apropriado para embarque do produto"
1156
        );
1157
        $this->dom->addChild(
1158
            $peri,
1159
            "xClaRisco",
1160
            $std->xClaRisco,
1161
            true,
1162
            "Classe ou subclasse/divisão, e risco subsidiário/risco secundário"
1163
        );
1164
        $this->dom->addChild(
1165
            $peri,
1166
            "grEmb",
1167
            $std->grEmb,
1168
            true,
1169
            "Grupo de Embalagem"
1170
        );
1171
        $this->dom->addChild(
1172
            $peri,
1173
            "qTotProd",
1174
            $std->qTotProd,
1175
            true,
1176
            "Quantidade total por produto"
1177
        );
1178
        $this->dom->addChild(
1179
            $peri,
1180
            "qVolTipo",
1181
            $std->qVolTipo,
1182
            true,
1183
            "Quantidade e Tipo de volumes"
1184
        );
1185
        return $peri;
1186
    }
1187
1188
    /**
1189
     * taginfNFe
1190
     * tag MDFe/infMDFe/infDoc/infMunDescarga/infNFe
1191
     *
1192
     * @param  stdClass $std
1193
     * @return DOMElement
1194
     */
1195
    public function taginfNFe(stdClass $std)
1196
    {
1197
        $possible = [
1198
            'chNFe',
1199
            'SegCodBarra',
1200
            'indReentrega',
1201
            'infUnidTransp',
1202
            'peri',
1203
            'nItem'
1204
        ];
1205
        $std = $this->equilizeParameters($std, $possible);
1206
        $infNFe = $this->dom->createElement("infNFe");
1207
        $this->dom->addChild(
1208
            $infNFe,
1209
            "chNFe",
1210
            $std->chNFe,
1211
            true,
1212
            "Chave de Acesso NFe"
1213
        );
1214
        $this->dom->addChild(
1215
            $infNFe,
1216
            "SegCodBarra",
1217
            $std->SegCodBarra,
1218
            false,
1219
            "Segundo código de barras do NFe"
1220
        );
1221
        $this->dom->addChild(
1222
            $infNFe,
1223
            "indReentrega",
1224
            $std->indReentrega,
1225
            false,
1226
            "Indicador de Reentrega"
1227
        );
1228
        if ($std->infUnidTransp) {
1229
            foreach ($std->infUnidTransp as $value) {
1230
                $this->dom->appChild($infNFe, $this->taginfUnidTransp($value), 'Falta tag "infUnidTransp"');
1231
            }
1232
        }
1233
        if ($std->peri) {
1234
            foreach ($std->peri as $value) {
1235
                $this->dom->appChild($infNFe, $this->tagperi($value), 'Falta tag "peri"');
1236
            }
1237
        }
1238
        $this->infNFe[$std->nItem][] = $infNFe;
1239
        return $infNFe;
1240
    }
1241
1242
    /**
1243
     * taginfMDFeTransp
1244
     * tag MDFe/infMDFe/infDoc/infMunDescarga/infMDFeTransp
1245
     *
1246
     * @param  stdClass $std
1247
     * @return DOMElement
1248
     */
1249
    public function taginfMDFeTransp(stdClass $std)
1250
    {
1251
        $possible = [
1252
            'chMDFe',
1253
            'indReentrega',
1254
            'nItem'
1255
        ];
1256
        $std = $this->equilizeParameters($std, $possible);
1257
        $infMDFeTransp = $this->dom->createElement("infMDFeTransp");
1258
        $this->dom->addChild(
1259
            $infMDFeTransp,
1260
            "chMDFe",
1261
            $std->chMDFe,
1262
            true,
1263
            "Chave de Acesso NFe"
1264
        );
1265
        $this->dom->addChild(
1266
            $infMDFeTransp,
1267
            "indReentrega",
1268
            $std->indReentrega,
1269
            false,
1270
            "Indicador de Reentrega"
1271
        );
1272
        if ($std->infUnidTransp) {
1273
            foreach ($std->infUnidTransp as $value) {
1274
                $this->dom->appChild($infMDFeTransp, $this->taginfUnidTransp($value), 'Falta tag "infUnidTransp"');
1275
            }
1276
        }
1277
        if ($std->peri) {
1278
            foreach ($std->peri as $value) {
1279
                $this->dom->appChild($infMDFeTransp, $this->tagperi($value), 'Falta tag "peri"');
1280
            }
1281
        }
1282
        $this->infMDFeTransp[$std->nItem][] = $infMDFeTransp;
1283
        return $infMDFeTransp;
1284
    }
1285
1286
    /**
1287
     * taginfUnidTransp
1288
     * tag MDFe/infMDFe/infDoc/infMunDescarga/(infCTe/infNFe)/infUnidTransp
1289
     *
1290
     * @param  stdClass $std
1291
     * @return DOMElement
1292
     */
1293
    private function taginfUnidTransp(stdClass $std)
1294
    {
1295
        $possible = [
1296
            'tpUnidTransp',
1297
            'idUnidTransp',
1298
            'qtdRat',
1299
            'lacUnidTransp',
1300
            'infUnidCarga'
1301
        ];
1302
        $std = $this->equilizeParameters($std, $possible);
1303
        $infUnidTransp = $this->dom->createElement("infUnidTransp");
1304
        $this->dom->addChild(
1305
            $infUnidTransp,
1306
            "tpUnidTransp",
1307
            $std->tpUnidTransp,
1308
            true,
1309
            "Tipo da Unidade de Transporte"
1310
        );
1311
        $this->dom->addChild(
1312
            $infUnidTransp,
1313
            "idUnidTransp",
1314
            $std->idUnidTransp,
1315
            false,
1316
            "Identificação da Unidade de Transporte"
1317
        );
1318
        if ($std->lacUnidTransp != null) {
1319
            $possible = [
1320
                'nLacre'
1321
            ];
1322
            $stdlacUnidTransp = $this->equilizeParameters($std->lacUnidTransp, $possible);
1323
            foreach ($stdlacUnidTransp->nLacre as $nLacre) {
1324
                $lacUnidTransp = $this->dom->createElement("lacUnidTransp");
1325
                $this->dom->addChild(
1326
                    $lacUnidTransp,
1327
                    "nLacre",
1328
                    $nLacre,
1329
                    true,
1330
                    "Número do lacre"
1331
                );
1332
                $this->dom->appChild($infUnidTransp, $lacUnidTransp, 'Falta tag "infUnidTransp"');
1333
            }
1334
        }
1335
        if ($std->infUnidCarga) {
1336
            foreach ($std->infUnidCarga as $value) {
1337
                $this->dom->appChild($infUnidTransp, $this->taginfUnidCarga($value), 'Falta tag "infUnidCarga"');
1338
            }
1339
        }
1340
        $this->dom->addChild(
1341
            $infUnidTransp,
1342
            "qtdRat",
1343
            $std->qtdRat,
1344
            false,
1345
            "Quantidade rateada (Peso,Volume) "
1346
        );
1347
        return $infUnidTransp;
1348
    }
1349
1350
    /**
1351
     * taginfUnidCarga
1352
     * tag MDFe/infMDFe/infDoc/infMunDescarga/(infCTe/infNFe)/infUnidCarga
1353
     *
1354
     * @param  stdClass $std
1355
     * @return DOMElement
1356
     */
1357
    private function taginfUnidCarga(stdClass $std)
1358
    {
1359
        $possible = [
1360
            'tpUnidCarga',
1361
            'idUnidCarga',
1362
            'lacUnidCarga',
1363
            'qtdRat'
1364
        ];
1365
        $std = $this->equilizeParameters($std, $possible);
1366
        $infUnidCarga = $this->dom->createElement("infUnidCarga");
1367
        $this->dom->addChild(
1368
            $infUnidCarga,
1369
            "tpUnidCarga",
1370
            $std->tpUnidCarga,
1371
            false,
1372
            "Tipo da Unidade de Carga"
1373
        );
1374
        $this->dom->addChild(
1375
            $infUnidCarga,
1376
            "idUnidCarga",
1377
            $std->idUnidCarga,
1378
            false,
1379
            "Identificação da Unidade de Carga "
1380
        );
1381
        if ($std->lacUnidCarga != null) {
1382
            $possible = [
1383
                'nLacre'
1384
            ];
1385
            $stdlacUnidCarga = $this->equilizeParameters($std->lacUnidCarga, $possible);
1386
            foreach ($stdlacUnidCarga->nLacre as $nLacre) {
1387
                $lacUnidCarga = $this->dom->createElement("lacUnidCarga");
1388
                $this->dom->addChild(
1389
                    $lacUnidCarga,
1390
                    "nLacre",
1391
                    $nLacre,
1392
                    true,
1393
                    "Número do lacre"
1394
                );
1395
                $this->dom->appChild($infUnidCarga, $lacUnidCarga, 'Falta tag "infUnidCarga"');
1396
            }
1397
        }
1398
        $this->dom->addChild(
1399
            $infUnidCarga,
1400
            "qtdRat",
1401
            $std->qtdRat,
1402
            false,
1403
            "Quantidade rateada (Peso,Volume) "
1404
        );
1405
        return $infUnidCarga;
1406
    }
1407
1408
    /**
1409
     * tagseg
1410
     * tag MDFe/infMDFe/seg
1411
     *
1412
     * @param  stdClass $std
1413
     * @return DOMElement
1414
     */
1415
    public function tagseg(stdClass $std)
1416
    {
1417
        $possible = [
1418
            'respSeg',
1419
            'CNPJ',
1420
            'CPF',
1421
            'infSeg',
1422
            'nApol',
1423
            'nAver'
1424
        ];
1425
        $std = $this->equilizeParameters($std, $possible);
1426
        $seg = $this->dom->createElement("seg");
1427
        $infResp = $this->dom->createElement("infResp");
1428
        $this->dom->addChild(
1429
            $infResp,
1430
            "respSeg",
1431
            $std->respSeg,
1432
            true,
1433
            "Responsável pelo seguro"
1434
        );
1435
        $this->dom->addChild(
1436
            $infResp,
1437
            "CNPJ",
1438
            $std->CNPJ,
1439
            false,
1440
            "Número do CNPJ do responsável pelo seguro"
1441
        );
1442
        $this->dom->addChild(
1443
            $infResp,
1444
            "CPF",
1445
            $std->CPF,
1446
            false,
1447
            "Número do CPF do responsável pelo seguro"
1448
        );
1449
        $this->dom->appChild($seg, $infResp, 'Falta tag "seg"');
1450
        if ($std->infSeg != null) {
1451
            $possible = [
1452
                'xSeg',
1453
                'CNPJ'
1454
            ];
1455
            $stdinfSeg = $this->equilizeParameters($std->infSeg, $possible);
1456
            $infSeg = $this->dom->createElement("infSeg");
1457
            $this->dom->addChild(
1458
                $infSeg,
1459
                "xSeg",
1460
                $stdinfSeg->xSeg,
1461
                true,
1462
                "Nome da Seguradora"
1463
            );
1464
            $this->dom->addChild(
1465
                $infSeg,
1466
                "CNPJ",
1467
                $stdinfSeg->CNPJ,
1468
                false,
1469
                "Número do CNPJ da seguradora"
1470
            );
1471
            $this->dom->appChild($seg, $infSeg, 'Falta tag "seg"');
1472
        }
1473
        $this->dom->addChild(
1474
            $seg,
1475
            "nApol",
1476
            $std->nApol,
1477
            false,
1478
            "Número da Apólice"
1479
        );
1480
        if ($std->nAver != null) {
1481
            foreach ($std->nAver as $nAver) {
1482
                $this->dom->addChild(
1483
                    $seg,
1484
                    "nAver",
1485
                    $nAver,
1486
                    true,
1487
                    "Número da Averbação"
1488
                );
1489
            }
1490
        }
1491
        $this->seg[] = $seg;
1492
        return $seg;
1493
    }
1494
1495
    /**
1496
     * tagTot
1497
     * tag MDFe/infMDFe/tot
1498
     *
1499
     * @param  stdClass $std
1500
     * @return DOMElement
1501
     */
1502
    public function tagtot(stdClass $std)
1503
    {
1504
        $possible = [
1505
            'qCTe',
1506
            'qNFe',
1507
            'qMDFe',
1508
            'vCarga',
1509
            'cUnid',
1510
            'qCarga'
1511
        ];
1512
        $std = $this->equilizeParameters($std, $possible);
1513
        if (!isset($std->qCTe)) {
1514
            $std->qCTe = 0;
1515
            foreach ($this->infCTe as $infCTe) {
0 ignored issues
show
Bug introduced by
The expression $this->infCTe 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...
1516
                $std->qCTe += count($infCTe);
1517
            }
1518
            if ($std->qCTe == 0) {
1519
                $std->qCTe = '';
1520
            }
1521
        }
1522
        if (!isset($std->qNFe)) {
1523
            $std->qNFe = 0;
1524
            foreach ($this->infNFe as $infNFe) {
0 ignored issues
show
Bug introduced by
The expression $this->infNFe 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...
1525
                $std->qNFe += count($infNFe);
1526
            }
1527
            if ($std->qNFe == 0) {
1528
                $std->qNFe = '';
1529
            }
1530
        }
1531
        if (!isset($std->qMDFe)) {
1532
            $std->qMDFe = 0;
1533
            foreach ($this->infMDFeTransp as $infMDFeTransp) {
0 ignored issues
show
Bug introduced by
The expression $this->infMDFeTransp 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...
1534
                $std->qMDFe += count($infMDFeTransp);
1535
            }
1536
            if ($std->qMDFe == 0) {
1537
                $std->qMDFe = '';
1538
            }
1539
        }
1540
        $tot = $this->dom->createElement("tot");
1541
        $this->dom->addChild(
1542
            $tot,
1543
            "qCTe",
1544
            $std->qCTe,
1545
            false,
1546
            "Quantidade total de CT-e relacionados no Manifesto"
1547
        );
1548
        $this->dom->addChild(
1549
            $tot,
1550
            "qNFe",
1551
            $std->qNFe,
1552
            false,
1553
            "Quantidade total de NF-e relacionados no Manifesto"
1554
        );
1555
        $this->dom->addChild(
1556
            $tot,
1557
            "qMDFe",
1558
            $std->qMDFe,
1559
            false,
1560
            "Quantidade total de MDF-e relacionados no Manifesto"
1561
        );
1562
        $this->dom->addChild(
1563
            $tot,
1564
            "vCarga",
1565
            $std->vCarga,
1566
            true,
1567
            "Valor total da mercadoria/carga transportada"
1568
        );
1569
        $this->dom->addChild(
1570
            $tot,
1571
            "cUnid",
1572
            $std->cUnid,
1573
            true,
1574
            "Código da unidade de medida do Peso Bruto da Carga / Mercadoria Transportada"
1575
        );
1576
        $this->dom->addChild(
1577
            $tot,
1578
            "qCarga",
1579
            $std->qCarga,
1580
            true,
1581
            "Peso Bruto Total da Carga / Mercadoria Transportada"
1582
        );
1583
        $this->tot = $tot;
1584
        return $tot;
1585
    }
1586
1587
    /**
1588
     * tagLacres
1589
     * tag MDFe/infMDFe/lacres
1590
     *
1591
     * @param  stdClass $std
1592
     * @return DOMElement
1593
     */
1594
    public function taglacres(stdClass $std)
1595
    {
1596
        $possible = [
1597
            'nLacre'
1598
        ];
1599
        $std = $this->equilizeParameters($std, $possible);
1600
        $lacres = $this->dom->createElement("lacres");
1601
        $this->dom->addChild(
1602
            $lacres,
1603
            "nLacre",
1604
            $std->nLacre,
1605
            false,
1606
            "Número do lacre"
1607
        );
1608
        $this->lacres[] = $lacres; //array de DOMNode
1609
        return $this->lacres;
1610
    }
1611
1612
    /**
1613
     * taginfAdic
1614
     * Grupo de Informações Adicionais Z01 pai A01
1615
     * tag MDFe/infMDFe/infAdic (opcional)
1616
     *
1617
     * @param  stdClass $std
1618
     * @return DOMElement
1619
     */
1620
    public function taginfAdic(stdClass $std)
1621
    {
1622
        $possible = [
1623
            'infAdFisco',
1624
            'infCpl'
1625
        ];
1626
        $std = $this->equilizeParameters($std, $possible);
1627
        $infAdic = $this->dom->createElement("infAdic");
1628
        $this->dom->addChild(
1629
            $infAdic,
1630
            "infAdFisco",
1631
            $std->infAdFisco,
1632
            false,
1633
            "Informações Adicionais de Interesse do Fisco"
1634
        );
1635
        $this->dom->addChild(
1636
            $infAdic,
1637
            "infCpl",
1638
            $std->infCpl,
1639
            false,
1640
            "Informações Complementares de interesse do Contribuinte"
1641
        );
1642
        $this->infAdic = $infAdic;
1643
        return $infAdic;
1644
    }
1645
1646
    /**
1647
     * tagautXML
1648
     * tag MDFe/infMDFe/autXML
1649
     *
1650
     * Autorizados para download do XML do MDF-e
1651
     *
1652
     * @param  stdClass $std
1653
     * @return DOMElement
1654
     */
1655
    public function tagautXML(stdClass $std)
1656
    {
1657
        $possible = [
1658
            'CNPJ',
1659
            'CPF'
1660
        ];
1661
        $std = $this->equilizeParameters($std, $possible);
1662
        $autXML = $this->dom->createElement("autXML");
1663
        $this->dom->addChild(
1664
            $autXML,
1665
            "CNPJ",
1666
            $std->CNPJ,
1667
            false,
1668
            "CNPJ do autorizado"
1669
        );
1670
        $this->dom->addChild(
1671
            $autXML,
1672
            "CPF",
1673
            $std->CPF,
1674
            false,
1675
            "CPF do autorizado"
1676
        );
1677
        $this->autXML[] = $autXML;
1678
        return $this->autXML;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->autXML; of type string|DOMNode adds the type string to the return on line 1678 which is incompatible with the return type documented by NFePHP\MDFe\Make::tagautXML of type DOMElement.
Loading history...
1679
    }
1680
1681
    /**
1682
     * buildInfModal
1683
     * tag MDFe/infMDFe/infModal
1684
     *
1685
     * @return DOMElement
1686
     */
1687
    private function buildInfModal()
1688
    {
1689
        $infModal = $this->dom->createElement("infModal");
1690
        $infModal->setAttribute("versaoModal", $this->versao);
1691
        $this->infModal = $infModal;
1692
        $modal = $this->ide->getElementsByTagName('modal')->item(0)->nodeValue;
1693
        /*
1694
         1 - Rodoviário;
1695
         2 - Aéreo;
1696
         3 - Aquaviário;
1697
         4 - Ferroviário;
1698
         */
1699
        if ($modal == '1') {
1700
            $this->tagrodo();
1701
        } elseif ($modal == '4') {
1702
            $this->tagferrov();
1703
        }
1704
        return $infModal;
1705
    }
1706
1707
    private function buildIde()
1708
    {
1709
        $this->dom->appChild($this->infMDFe, $this->ide, 'Falta tag "ide"');
1710
        $UFFim = $this->ide->getElementsByTagName('UFFim')->item(0);
1711
        foreach ($this->infPercurso as $percurso) {
0 ignored issues
show
Bug introduced by
The expression $this->infPercurso 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...
1712
            $this->dom->insertAfter($percurso, $UFFim);
1713
        }
1714
        foreach ($this->infMunCarrega as $munCarrega) {
0 ignored issues
show
Bug introduced by
The expression $this->infMunCarrega 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...
1715
            $this->dom->insertAfter($munCarrega, $UFFim);
1716
        }
1717
    }
1718
1719
    /**
1720
     * tagAereo
1721
     * tag MDFe/infMDFe/infModal/aereo
1722
     *
1723
     * @return DOMElement
1724
     */
1725
1726
    public function tagaereo(stdClass $std)
1727
    {
1728
        $possible = [
1729
            'nac',
1730
            'matr',
1731
            'nVoo',
1732
            'cAerEmb',
1733
            'cAerDes',
1734
            'dVoo'
1735
        ];
1736
        $std = $this->equilizeParameters($std, $possible);
1737
        $aereo = $this->dom->createElement("aereo");
1738
        $identificador = '[1] <aereo> - ';
1739
        $this->dom->addChild(
1740
            $aereo,
1741
            "nac",
1742
            $std->nac,
1743
            true,
1744
            $identificador . "Marca da Nacionalidade da aeronave"
1745
        );
1746
        $this->dom->addChild(
1747
            $aereo,
1748
            "matr",
1749
            $std->matr,
1750
            true,
1751
            $identificador . "Marca de Matrícula da aeronave"
1752
        );
1753
        $this->dom->addChild(
1754
            $aereo,
1755
            "nVoo",
1756
            $std->nVoo,
1757
            true,
1758
            $identificador . "Número do Vôo"
1759
        );
1760
        $this->dom->addChild(
1761
            $aereo,
1762
            "cAerEmb",
1763
            $std->cAerEmb,
1764
            true,
1765
            $identificador . "Aeródromo de Embarque - Código IATA"
1766
        );
1767
        $this->dom->addChild(
1768
            $aereo,
1769
            "cAerDes",
1770
            $std->cAerDes,
1771
            true,
1772
            $identificador . "Aeródromo de Destino - Código IATA"
1773
        );
1774
        $this->dom->addChild(
1775
            $aereo,
1776
            "dVoo",
1777
            $std->dVoo,
1778
            true,
1779
            $identificador . "Data do Vôo"
1780
        );
1781
        $this->aereo = $aereo;
1782
        return $aereo;
1783
    }
1784
1785
1786
    /**
1787
     * tagtrem
1788
     * tag MDFe/infMDFe/infModal/ferrov/trem
1789
     *
1790
     * @return DOMElement
1791
     */
1792
1793
    public function tagtrem(stdClass $std)
1794
    {
1795
        $possible = [
1796
            'xPref',
1797
            'dhTrem',
1798
            'xOri',
1799
            'xDest',
1800
            'qVag'
1801
        ];
1802
        $std = $this->equilizeParameters($std, $possible);
1803
        $trem = $this->dom->createElement("trem");
1804
        $identificador = '[1] <trem> - ';
1805
        $this->dom->addChild(
1806
            $trem,
1807
            "xPref",
1808
            $std->xPref,
1809
            true,
1810
            $identificador . "Prefixo do Trem"
1811
        );
1812
        $this->dom->addChild(
1813
            $trem,
1814
            "dhTrem",
1815
            $std->dhTrem,
1816
            false,
1817
            $identificador . "Data e hora de liberação do trem na origem"
1818
        );
1819
        $this->dom->addChild(
1820
            $trem,
1821
            "xOri",
1822
            $std->xOri,
1823
            true,
1824
            $identificador . "Origem do Trem"
1825
        );
1826
        $this->dom->addChild(
1827
            $trem,
1828
            "xDest",
1829
            $std->xDest,
1830
            true,
1831
            $identificador . "Destino do Trem"
1832
        );
1833
        $this->dom->addChild(
1834
            $trem,
1835
            "qVag",
1836
            $std->qVag,
1837
            true,
1838
            $identificador . "Quantidade de vagões carregados"
1839
        );
1840
        $this->trem = $trem;
1841
        return $trem;
1842
    }
1843
1844
    /**
1845
     * tagVag
1846
     * tag MDFe/infMDFe/infModal/ferrov/trem/vag
1847
     *
1848
     * @param string $serie
1849
     * @param string $nVag
0 ignored issues
show
Bug introduced by
There is no parameter named $serie. 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...
1850
     * @param string $nSeq
0 ignored issues
show
Bug introduced by
There is no parameter named $nVag. 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...
1851
     * @param string $tonUtil
0 ignored issues
show
Bug introduced by
There is no parameter named $nSeq. 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...
1852
     *
0 ignored issues
show
Bug introduced by
There is no parameter named $tonUtil. 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...
1853
     * @return DOMElement
1854
     */
1855
1856
    public function tagVag(stdClass $std)
1857
    {
1858
        $possible = [
1859
            'pesoBC',
1860
            'pesoR',
1861
            'tpVag',
1862
            'serie',
1863
            'nVag',
1864
            'nSeq',
1865
            'TU'
1866
        ];
1867
        $identificador = '[1] <vag> - ';
1868
        $std = $this->equilizeParameters($std, $possible);
1869
        $vag = $this->dom->createElement("vag");
1870
        $this->dom->addChild(
1871
            $vag,
1872
            "pesoBC",
1873
            $std->pesoBC,
1874
            true,
1875
            $identificador . "Peso Base de Cálculo de Frete em Toneladas"
1876
        );
1877
        $this->dom->addChild(
1878
            $vag,
1879
            "pesoR",
1880
            $std->pesoR,
1881
            true,
1882
            $identificador . "Peso Real em Toneladas"
1883
        );
1884
        $this->dom->addChild(
1885
            $vag,
1886
            "tpVag",
1887
            $std->tpVag,
1888
            false,
1889
            $identificador . "Tipo de Vagão"
1890
        );
1891
        $this->dom->addChild(
1892
            $vag,
1893
            "serie",
1894
            $std->serie,
1895
            true,
1896
            $identificador . "Serie de Identificação do vagão"
1897
        );
1898
        $this->dom->addChild(
1899
            $vag,
1900
            "nVag",
1901
            $std->nVag,
1902
            true,
1903
            $identificador . "Número de Identificação do vagão"
1904
        );
1905
        $this->dom->addChild(
1906
            $vag,
1907
            "nSeq",
1908
            $std->nSeq,
1909
            false,
1910
            $identificador . "Sequência do vagão na composição"
1911
        );
1912
        $this->dom->addChild(
1913
            $vag,
1914
            "TU",
1915
            $std->TU,
1916
            true,
1917
            $identificador . "Tonelada Útil"
1918
        );
1919
        $this->vag[] = $vag;
1920
        return $vag;
1921
    }
1922
1923
    /**
1924
     * tagaquav
1925
     * tag MDFe/infMDFe/infModal/aquav
1926
     *
1927
     * @param stdClass $std
1928
     * @return DOMElement
1929
     */
1930
1931
    public function tagaquav(stdClass $std)
1932
    {
1933
        $possible = [
1934
            'irin',
1935
            'tpEmb',
1936
            'cEmbar',
1937
            'xEmbar',
1938
            'nViag',
1939
            'cPrtEmb',
1940
            'cPrtDest',
1941
            'prtTrans',
1942
            'tpNav',
1943
            'infTermCarreg',
1944
            'infTermDescarreg',
1945
            'infEmbComb',
1946
            'infUnidCargaVazia',
1947
            'infUnidTranspVazia'
1948
        ];
1949
        $identificador = '[1] <aquav> - ';
1950
        $std = $this->equilizeParameters($std, $possible);
1951
        $aquav = $this->dom->createElement("aquav");
1952
        $this->dom->addChild(
1953
            $aquav,
1954
            "irin",
1955
            $std->irin,
1956
            true,
1957
            $identificador . "Irin do navio sempre deverá ser informado"
1958
        );
1959
        $this->dom->addChild(
1960
            $aquav,
1961
            "tpEmb",
1962
            $std->tpEmb,
1963
            true,
1964
            $identificador . "Código do tipo de embarcação"
1965
        );
1966
        $this->dom->addChild(
1967
            $aquav,
1968
            "cEmbar",
1969
            $std->cEmbar,
1970
            true,
1971
            $identificador . "Código da embarcação"
1972
        );
1973
        $this->dom->addChild(
1974
            $aquav,
1975
            "xEmbar",
1976
            $std->xEmbar,
1977
            true,
1978
            $identificador . "Nome da embarcação"
1979
        );
1980
        $this->dom->addChild(
1981
            $aquav,
1982
            "nViag",
1983
            $std->nViag,
1984
            true,
1985
            $identificador . "Número da Viagem"
1986
        );
1987
        $this->dom->addChild(
1988
            $aquav,
1989
            "cPrtEmb",
1990
            $std->cPrtEmb,
1991
            true,
1992
            $identificador . "Código do Porto de Embarque"
1993
        );
1994
        $this->dom->addChild(
1995
            $aquav,
1996
            "cPrtDest",
1997
            $std->cPrtDest,
1998
            true,
1999
            $identificador . "Código do Porto de Destino"
2000
        );
2001
        $this->dom->addChild(
2002
            $aquav,
2003
            "prtTrans",
2004
            $std->prtTrans,
2005
            false,
2006
            $identificador . "Porto de Transbordo"
2007
        );
2008
        $this->dom->addChild(
2009
            $aquav,
2010
            "tpNav",
2011
            $std->tpNav,
2012
            false,
2013
            $identificador . "Tipo de Navegação"
2014
        );
2015
        if ($std->infTermCarreg) {
2016
            foreach ($std->infTermCarreg as $value) {
2017
                $this->dom->appChild($aquav, $this->taginfTermCarreg($value), 'Falta tag "infTermCarreg"');
2018
            }
2019
        }
2020
        if ($std->infTermDescarreg) {
2021
            foreach ($std->infTermDescarreg as $value) {
2022
                $this->dom->appChild($aquav, $this->taginfTermDescarreg($value), 'Falta tag "infTermDescarreg"');
2023
            }
2024
        }
2025
        if ($std->infEmbComb) {
2026
            foreach ($std->infEmbComb as $value) {
2027
                $this->dom->appChild($aquav, $this->taginfEmbComb($value), 'Falta tag "infEmbComb"');
2028
            }
2029
        }
2030
        if ($std->infUnidCargaVazia) {
2031
            foreach ($std->infUnidCargaVazia as $value) {
2032
                $this->dom->appChild($aquav, $this->taginfUnidCargaVazia($value), 'Falta tag "infUnidCargaVazia"');
2033
            }
2034
        }
2035
        if ($std->infUnidTranspVazia) {
2036
            foreach ($std->infUnidTranspVazia as $value) {
2037
                $this->dom->appChild($aquav, $this->taginfUnidTranspVazia($value), 'Falta tag "infUnidTranspVazia"');
2038
            }
2039
        }
2040
        $this->aquav = $aquav;
2041
        return $aquav;
2042
    }
2043
2044
    /**
2045
     * infUnidTranspVazia
2046
     * tag MDFe/infMDFe/infModal/Aqua/infUnidTranspVazia
2047
     *
2048
     * @return DOMElement
2049
     */
2050
    public function taginfUnidTranspVazia(stdClass $std)
2051
    {
2052
        $possible = [
2053
            'idUnidTranspVazia',
2054
            'tpUnidTranspVazia'
2055
        ];
2056
        $identificador = '[1] <infUnidTranspVazia> - ';
2057
        $std = $this->equilizeParameters($std, $possible);
2058
        $infUnidTranspVazia = $this->dom->createElement("infUnidTranspVazia");
2059
        $this->dom->addChild(
2060
            $infUnidTranspVazia,
2061
            "idUnidTranspVazia",
2062
            $std->idUnidTranspVazia,
2063
            true,
2064
            $identificador . "dentificação da unidades de transporte vazia"
2065
        );
2066
        $this->dom->addChild(
2067
            $infUnidTranspVazia,
2068
            "tpUnidTranspVazia",
2069
            $std->tpUnidTranspVazia,
2070
            true,
2071
            $identificador . "Tipo da unidade de transporte vazia"
2072
        );
2073
        return $infUnidTranspVazia;
2074
    }
2075
2076
    /**
2077
     * infUnidCargaVazia
2078
     * tag MDFe/infMDFe/infModal/Aqua/infUnidCargaVazia
2079
     *
2080
     * @return DOMElement
2081
     */
2082
    public function taginfUnidCargaVazia(stdClass $std)
2083
    {
2084
        $possible = [
2085
            'idUnidCargaVazia',
2086
            'tpUnidCargaVazia'
2087
        ];
2088
        $identificador = '[1] <infUnidCargaVazia> - ';
2089
        $std = $this->equilizeParameters($std, $possible);
2090
        $infUnidCargaVazia = $this->dom->createElement("infUnidCargaVazia");
2091
        $this->dom->addChild(
2092
            $infUnidCargaVazia,
2093
            "idUnidCargaVazia",
2094
            $std->idUnidCargaVazia,
2095
            true,
2096
            $identificador . "Identificação da unidades de carga vazia"
2097
        );
2098
        $this->dom->addChild(
2099
            $infUnidCargaVazia,
2100
            "tpUnidCargaVazia",
2101
            $std->tpUnidCargaVazia,
2102
            true,
2103
            $identificador . "Tipo da unidade de carga vazia"
2104
        );
2105
        return $infUnidCargaVazia;
2106
    }
2107
2108
    /**
2109
     * taginfTermDescarreg
2110
     * tag MDFe/infMDFe/infModal/Aqua/infTermDescarreg
2111
     *
2112
     * @return DOMElement
2113
     */
2114
    public function taginfTermDescarreg(stdClass $std)
2115
    {
2116
        $possible = [
2117
            'cTermDescarreg',
2118
            'xTermDescarreg'
2119
        ];
2120
        $identificador = '[1] <infTermDescarreg> - ';
2121
        $std = $this->equilizeParameters($std, $possible);
2122
        $infTermDescarreg = $this->dom->createElement("infTermDescarreg");
2123
        $this->dom->addChild(
2124
            $infTermDescarreg,
2125
            "cTermDescarreg",
2126
            $std->cTermDescarreg,
2127
            true,
2128
            $identificador . "Código do Terminal de Descarregamento"
2129
        );
2130
        $this->dom->addChild(
2131
            $infTermDescarreg,
2132
            "xTermDescarreg",
2133
            $std->xTermDescarreg,
2134
            true,
2135
            $identificador . "Nome do Terminal de Descarregamento"
2136
        );
2137
        return $infTermDescarreg;
2138
    }
2139
2140
    /**
2141
     * tagInfTermCarreg
2142
     * tag MDFe/infMDFe/infModal/aquav/infTermCarreg
2143
     *
2144
     * @return DOMElement
2145
     */
2146
    public function taginfTermCarreg(stdClass $std)
2147
    {
2148
        $possible = [
2149
            'cTermCarreg',
2150
            'xTermCarreg'
2151
        ];
2152
        $identificador = '[1] <infTermCarreg> - ';
2153
        $std = $this->equilizeParameters($std, $possible);
2154
        $infTermCarreg = $this->dom->createElement("infTermCarreg");
2155
2156
        $this->dom->addChild(
2157
            $infTermCarreg,
2158
            "cTermCarreg",
2159
            $std->cTermCarreg,
2160
            true,
2161
            $identificador . "Código do Terminal de Carregamento"
2162
        );
2163
        $this->dom->addChild(
2164
            $infTermCarreg,
2165
            "xTermCarreg",
2166
            $std->xTermCarreg,
2167
            true,
2168
            $identificador . "Nome do Terminal de Carregamento"
2169
        );
2170
        return $infTermCarreg;
2171
    }
2172
2173
    /**
2174
     * tagInfTermCarreg
2175
     * tag MDFe/infMDFe/infModal/aquav/infEmbComb
2176
     *
2177
     * @param stdClass $std
2178
     * @return DOMElement
2179
     */
2180
    public function taginfEmbComb(stdClass $std)
2181
    {
2182
        $possible = [
2183
            'cEmbComb',
2184
            'xBalsa'
2185
        ];
2186
        $identificador = '[1] <infEmbComb> - ';
2187
        $std = $this->equilizeParameters($std, $possible);
2188
        $infEmbComb = $this->dom->createElement("infEmbComb");
2189
2190
        $this->dom->addChild(
2191
            $infEmbComb,
2192
            "cEmbComb",
2193
            $std->cEmbComb,
2194
            true,
2195
            $identificador . "Código da embarcação do comboio"
2196
        );
2197
        $this->dom->addChild(
2198
            $infEmbComb,
2199
            "xBalsa",
2200
            $std->xBalsa,
2201
            true,
2202
            $identificador . "Identificador da Balsa"
2203
        );
2204
        return $infEmbComb;
2205
    }
2206
2207
    /**
2208
     * condutor
2209
     * tag MDFe/infMDFe/infModal/rodo/veicTracao/condutor
2210
     *
2211
     * @param  string $cEmbComb
0 ignored issues
show
Bug introduced by
There is no parameter named $cEmbComb. 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...
2212
     *
2213
     * @return DOMElement
2214
     */
2215
    private function tagcondutor(stdClass $std)
2216
    {
2217
        $possible = [
2218
            'xNome',
2219
            'CPF'
2220
        ];
2221
        $std = $this->equilizeParameters($std, $possible);
2222
        $condutor = $this->dom->createElement("condutor");
2223
        $identificador = '[4] <condutor> - ';
2224
        $this->dom->addChild(
2225
            $condutor,
2226
            "xNome",
2227
            $std->xNome,
2228
            true,
2229
            $identificador . "Nome do Condutor "
2230
        );
2231
        $this->dom->addChild(
2232
            $condutor,
2233
            "CPF",
2234
            $std->CPF,
2235
            true,
2236
            $identificador . "CPF do Condutor "
2237
        );
2238
        return $condutor;
2239
    }
2240
2241
    /**
2242
     * tagVeicTracao
2243
     * tag MDFe/infMDFe/infModal/rodo/veicTracao
2244
     *
2245
     * @param  stdClass $std
2246
     * @return DOMElement
2247
     */
2248
    public function tagveicTracao(stdClass $std)
2249
    {
2250
        $possible = [
2251
            'cInt',
2252
            'placa',
2253
            'RENAVAM',
2254
            'tara',
2255
            'capKG',
2256
            'capM3',
2257
            'prop',
2258
            'tpRod',
2259
            'tpCar',
2260
            'UF',
2261
            'condutor'
2262
        ];
2263
        $std = $this->equilizeParameters($std, $possible);
2264
        $veicTracao = $this->dom->createElement("veicTracao");
2265
        $identificador = '[4] <disp> - ';
2266
        $this->dom->addChild(
2267
            $veicTracao,
2268
            "cInt",
2269
            $std->cInt,
2270
            false,
2271
            $identificador . "Código interno do veículo"
2272
        );
2273
        $this->dom->addChild(
2274
            $veicTracao,
2275
            "placa",
2276
            $std->placa,
2277
            true,
2278
            $identificador . "Placa do veículo"
2279
        );
2280
        $this->dom->addChild(
2281
            $veicTracao,
2282
            "RENAVAM",
2283
            $std->RENAVAM,
2284
            false,
2285
            $identificador . "RENAVAM"
2286
        );
2287
        $this->dom->addChild(
2288
            $veicTracao,
2289
            "tara",
2290
            $std->tara,
2291
            true,
2292
            $identificador . "Tara em KG"
2293
        );
2294
        $this->dom->addChild(
2295
            $veicTracao,
2296
            "capKG",
2297
            $std->capKG,
2298
            false,
2299
            $identificador . "Capacidade em KG"
2300
        );
2301
        $this->dom->addChild(
2302
            $veicTracao,
2303
            "capM3",
2304
            $std->capM3,
2305
            false,
2306
            $identificador . "Capacidade em M3"
2307
        );
2308
        if ($std->prop != null) {
2309
            $possible = [
2310
                'CPF',
2311
                'CNPJ',
2312
                'RNTRC',
2313
                'xNome',
2314
                'IE',
2315
                'UF',
2316
                'tpProp'
2317
            ];
2318
            $identificadorProp = '[4] <prop> - ';
2319
            $stdprop = $this->equilizeParameters($std->prop, $possible);
2320
            $prop = $this->dom->createElement("prop");
2321
            if ($stdprop->CPF) {
2322
                $this->dom->addChild(
2323
                    $prop,
2324
                    "CPF",
2325
                    $stdprop->CPF,
2326
                    true,
2327
                    $identificadorProp . "Número do CPF"
2328
                );
2329
            } else {
2330
                $this->dom->addChild(
2331
                    $prop,
2332
                    "CNPJ",
2333
                    $stdprop->CNPJ,
2334
                    true,
2335
                    $identificadorProp . "Número do CNPJ"
2336
                );
2337
            }
2338
            $this->dom->addChild(
2339
                $prop,
2340
                "RNTRC",
2341
                $stdprop->RNTRC,
2342
                true,
2343
                $identificadorProp . "RNTRC"
2344
            );
2345
            $this->dom->addChild(
2346
                $prop,
2347
                "xNome",
2348
                $stdprop->xNome,
2349
                true,
2350
                $identificadorProp . "Razão Social"
2351
            );
2352
            $this->dom->addChild(
2353
                $prop,
2354
                "IE",
2355
                $stdprop->IE,
2356
                true,
2357
                $identificadorProp . "Inscrição Estadual"
2358
            );
2359
            $this->dom->addChild(
2360
                $prop,
2361
                "UF",
2362
                $stdprop->UF,
2363
                true,
2364
                $identificadorProp . "Unidade da Federação"
2365
            );
2366
            $this->dom->addChild(
2367
                $prop,
2368
                "tpProp",
2369
                $stdprop->tpProp,
2370
                true,
2371
                $identificadorProp . "Tipo Proprietário"
2372
            );
2373
            $this->dom->appChild($veicTracao, $prop, 'Falta tag "veicTracao"');
2374
        }
2375
        if ($std->condutor) {
2376
            foreach ($std->condutor as $value) {
2377
                $this->dom->appChild($veicTracao, $this->tagcondutor($value), 'Falta tag "condutor"');
2378
            }
2379
        }
2380
        $this->dom->addChild(
2381
            $veicTracao,
2382
            "tpRod",
2383
            $std->tpRod,
2384
            true,
2385
            $identificador . "Tipo de rodado"
2386
        );
2387
        $this->dom->addChild(
2388
            $veicTracao,
2389
            "tpCar",
2390
            $std->tpCar,
2391
            true,
2392
            $identificador . "Tipo de carroceria"
2393
        );
2394
        $this->dom->addChild(
2395
            $veicTracao,
2396
            "UF",
2397
            $std->UF,
2398
            true,
2399
            $identificador . "UF de licenciamento do veículo"
2400
        );
2401
        $this->veicTracao = $veicTracao;
2402
        return $veicTracao;
2403
    }
2404
2405
    /**
2406
     * tagVeicReboque
2407
     * tag MDFe/infMDFe/infModal/rodo/VeicReboque
2408
     *
2409
     * @param  stdClass $std
2410
     * @return DOMElement
2411
     */
2412
    public function tagveicReboque(stdClass $std)
2413
    {
2414
        $possible = [
2415
            'cInt',
2416
            'placa',
2417
            'RENAVAM',
2418
            'tara',
2419
            'capKG',
2420
            'capM3',
2421
            'prop',
2422
            'tpCar',
2423
            'UF'
2424
        ];
2425
        $std = $this->equilizeParameters($std, $possible);
2426
        $veicReboque = $this->dom->createElement("veicReboque");
2427
        $identificador = '[4] <veicReboque> - ';
2428
        $this->dom->addChild(
2429
            $veicReboque,
2430
            "cInt",
2431
            $std->cInt,
2432
            false,
2433
            $identificador . "Código interno do veículo"
2434
        );
2435
        $this->dom->addChild(
2436
            $veicReboque,
2437
            "placa",
2438
            $std->placa,
2439
            true,
2440
            $identificador . "Placa do veículo"
2441
        );
2442
        $this->dom->addChild(
2443
            $veicReboque,
2444
            "RENAVAM",
2445
            $std->RENAVAM,
2446
            false,
2447
            $identificador . "RENAVAM"
2448
        );
2449
        $this->dom->addChild(
2450
            $veicReboque,
2451
            "tara",
2452
            $std->tara,
2453
            true,
2454
            $identificador . "Tara em KG"
2455
        );
2456
        $this->dom->addChild(
2457
            $veicReboque,
2458
            "capKG",
2459
            $std->capKG,
2460
            false,
2461
            $identificador . "Capacidade em KG"
2462
        );
2463
        $this->dom->addChild(
2464
            $veicReboque,
2465
            "capM3",
2466
            $std->capM3,
2467
            false,
2468
            $identificador . "Capacidade em M3"
2469
        );
2470
        if ($std->prop != null) {
2471
            $identificadorprop = '[4] <prop> - ';
2472
            $possible = [
2473
                'CPF',
2474
                'CNPJ',
2475
                'RNTRC',
2476
                'xNome',
2477
                'IE',
2478
                'UF',
2479
                'tpProp'
2480
            ];
2481
            $stdprop = $this->equilizeParameters($std->prop, $possible);
2482
            $prop = $this->dom->createElement("prop");
2483
            if ($stdprop->CPF) {
2484
                $this->dom->addChild(
2485
                    $prop,
2486
                    "CPF",
2487
                    $stdprop->CPF,
2488
                    true,
2489
                    $identificadorprop . "Número do CPF"
2490
                );
2491
            } else {
2492
                $this->dom->addChild(
2493
                    $prop,
2494
                    "CNPJ",
2495
                    $stdprop->CNPJ,
2496
                    true,
2497
                    $identificadorprop . "Número do CNPJ"
2498
                );
2499
            }
2500
            $this->dom->addChild(
2501
                $prop,
2502
                "RNTRC",
2503
                $stdprop->RNTRC,
2504
                true,
2505
                $identificadorprop . "RNTRC"
2506
            );
2507
            $this->dom->addChild(
2508
                $prop,
2509
                "xNome",
2510
                $stdprop->xNome,
2511
                true,
2512
                $identificadorprop . "Razão Social"
2513
            );
2514
            $this->dom->addChild(
2515
                $prop,
2516
                "IE",
2517
                $stdprop->IE,
2518
                true,
2519
                $identificadorprop . "Inscrição Estadual"
2520
            );
2521
            $this->dom->addChild(
2522
                $prop,
2523
                "UF",
2524
                $stdprop->UF,
2525
                true,
2526
                $identificadorprop . "Unidade da Federação"
2527
            );
2528
            $this->dom->addChild(
2529
                $prop,
2530
                "tpProp",
2531
                $stdprop->tpProp,
2532
                true,
2533
                $identificadorprop . "Tipo Proprietário"
2534
            );
2535
            $this->dom->appChild($veicReboque, $prop, 'Falta tag "veicReboque"');
2536
        }
2537
        $this->dom->addChild(
2538
            $veicReboque,
2539
            "tpCar",
2540
            $std->tpCar,
2541
            true,
2542
            $identificador . "Tipo de carroceria"
2543
        );
2544
        $this->dom->addChild(
2545
            $veicReboque,
2546
            "UF",
2547
            $std->UF,
2548
            true,
2549
            $identificador . "UF de licenciamento do veículo"
2550
        );
2551
        $this->veicReboque[] = $veicReboque;
2552
        return $veicReboque;
2553
    }
2554
2555
    /**
2556
     * tagcodAgPorto
2557
     * tag MDFe/infMDFe/infModal/rodo/codAgPorto
2558
     *
2559
     * @param  stdClass $std
2560
     * @return DOMElement
2561
     */
2562
    public function tagcodAgPorto(stdClass $std)
2563
    {
2564
        $possible = [
2565
            'codAgPorto'
2566
        ];
2567
        $std = $this->equilizeParameters($std, $possible);
2568
        $this->dom->addChild(
2569
            $this->rodo,
2570
            "codAgPorto",
2571
            $std->codAgPorto,
2572
            false,
2573
            "Código de Agendamento no porto"
2574
        );
2575
        return $this->rodo;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->rodo; of type string|DOMNode adds the type string to the return on line 2575 which is incompatible with the return type documented by NFePHP\MDFe\Make::tagcodAgPorto of type DOMElement.
Loading history...
2576
    }
2577
2578
    /**
2579
     * taglacRodo
2580
     * tag MDFe/infMDFe/infModal/rodo/lacRodo
2581
     *
2582
     * @param  stdClass $std
2583
     * @return DOMElement
2584
     */
2585
    public function taglacRodo(stdClass $std)
2586
    {
2587
        $possible = [
2588
            'nLacre'
2589
        ];
2590
        $std = $this->equilizeParameters($std, $possible);
2591
        $lacRodo = $this->dom->createElement("lacRodo");
2592
        $this->dom->addChild(
2593
            $lacRodo,
2594
            "nLacre",
2595
            $std->nLacre,
2596
            true,
2597
            "Número do Lacre"
2598
        );
2599
        $this->lacRodo[] = $lacRodo;
2600
        return $lacRodo;
2601
    }
2602
2603
    /**
2604
     * Informações do Responsável técnico ZD01 pai A01
2605
     * tag NFe/infNFe/infRespTec (opcional)
2606
     * @param stdClass $std
2607
     * @return DOMElement
2608
     * @throws RuntimeException
2609
     */
2610
    public function taginfRespTec(stdClass $std)
2611
    {
2612
        $possible = [
2613
            'CNPJ',
2614
            'xContato',
2615
            'email',
2616
            'fone',
2617
            'CSRT',
2618
            'idCSRT'
2619
        ];
2620
2621
        $std = $this->equilizeParameters($std, $possible);
2622
        $infRespTec = $this->dom->createElement("infRespTec");
2623
        $this->dom->addChild(
2624
            $infRespTec,
2625
            "CNPJ",
2626
            $std->CNPJ,
2627
            true,
2628
            "Informar o CNPJ da pessoa jurídica responsável pelo sistema "
2629
            . "utilizado na emissão do documento fiscal eletrônico"
2630
        );
2631
        $this->dom->addChild(
2632
            $infRespTec,
2633
            "xContato",
2634
            $std->xContato,
2635
            true,
2636
            "Informar o nome da pessoa a ser contatada na empresa desenvolvedora "
2637
            . "do sistema utilizado na emissão do documento fiscal eletrônico"
2638
        );
2639
        $this->dom->addChild(
2640
            $infRespTec,
2641
            "email",
2642
            $std->email,
2643
            true,
2644
            "Informar o e-mail da pessoa a ser contatada na empresa "
2645
            . "desenvolvedora do sistema."
2646
        );
2647
        $this->dom->addChild(
2648
            $infRespTec,
2649
            "fone",
2650
            $std->fone,
2651
            true,
2652
            "Informar o telefone da pessoa a ser contatada na empresa "
2653
            . "desenvolvedora do sistema."
2654
        );
2655
        if (!empty($std->CSRT) && !empty($std->idCSRT)) {
2656
            $this->csrt = $std->CSRT;
0 ignored issues
show
Bug introduced by
The property csrt 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...
2657
            $this->dom->addChild(
2658
                $infRespTec,
2659
                "idCSRT",
2660
                $std->idCSRT,
2661
                true,
2662
                "Identificador do CSRT utilizado para montar o hash do CSRT"
2663
            );
2664
            $this->dom->addChild(
2665
                $infRespTec,
2666
                "hashCSRT",
2667
                $std->CSRT,
2668
                true,
2669
                "hash do CSRT"
2670
            );
2671
        }
2672
        $this->infRespTec = $infRespTec;
0 ignored issues
show
Bug introduced by
The property infRespTec 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...
2673
        return $infRespTec;
2674
    }
2675
2676
    /**
2677
     * buildMDFe
2678
     * Tag raiz da MDFe
2679
     * tag MDFe DOMNode
2680
     * Função chamada pelo método [ monta ]
2681
     *
2682
     * @return DOMElement
2683
     */
2684
    protected function buildMDFe()
2685
    {
2686
        if (empty($this->MDFe)) {
2687
            $this->MDFe = $this->dom->createElement("MDFe");
2688
            $this->MDFe->setAttribute("xmlns", "http://www.portalfiscal.inf.br/mdfe");
2689
        }
2690
        return $this->MDFe;
2691
    }
2692
2693
    /**
2694
     * checkMDFKey
2695
     * Remonta a chave do MDFe de 44 digitos com base em seus dados
2696
     * Isso é útil no caso da chave informada estar errada
2697
     * se a chave estiver errada a mesma é substituida
2698
     *
2699
     * @param object $dom
2700
     */
2701
    private function checkMDFKey($dom)
2702
    {
2703
        $infMDFe = $dom->getElementsByTagName("infMDFe")->item(0);
2704
        $ide = $dom->getElementsByTagName("ide")->item(0);
2705
        $emit = $dom->getElementsByTagName("emit")->item(0);
2706
        $cUF = $ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2707
        $dhEmi = $ide->getElementsByTagName('dhEmi')->item(0)->nodeValue;
2708
        if (!empty($emit->getElementsByTagName('CNPJ')->item(0)->nodeValue)) {
2709
            $doc = $emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2710
        } else {
2711
            $doc = $emit->getElementsByTagName('CPF')->item(0)->nodeValue;
2712
        }
2713
        $mod = $ide->getElementsByTagName('mod')->item(0)->nodeValue;
2714
        $serie = $ide->getElementsByTagName('serie')->item(0)->nodeValue;
2715
        $nMDF = $ide->getElementsByTagName('nMDF')->item(0)->nodeValue;
2716
        $tpEmis = $ide->getElementsByTagName('tpEmis')->item(0)->nodeValue;
2717
        $cNF = $ide->getElementsByTagName('cMDF')->item(0)->nodeValue;
2718
        $chave = str_replace('MDFe', '', $infMDFe->getAttribute("Id"));
2719
        $dt = new \DateTime($dhEmi);
2720
        $chaveMontada = Keys::build(
2721
            $cUF,
2722
            $dt->format('y'),
2723
            $dt->format('m'),
2724
            $doc,
2725
            $mod,
2726
            $serie,
2727
            $nMDF,
2728
            $tpEmis,
2729
            $cNF
2730
        );
2731
2732
        //caso a chave contida na NFe esteja errada
2733
        //substituir a chave
2734
        if ($chaveMontada != $chave) {
2735
            $ide->getElementsByTagName('cDV')->item(0)->nodeValue = substr($chaveMontada, -1);
2736
            $infMDFe = $dom->getElementsByTagName("infMDFe")->item(0);
2737
            $infMDFe->setAttribute("Id", "MDFe" . $chaveMontada);
2738
            $infMDFe->setAttribute("versao", $this->versao);
2739
            $this->chMDFe = $chaveMontada;
2740
        }
2741
    }
2742
2743
    /**
2744
     * Retorna os erros detectados
2745
     * @return array
2746
     */
2747
    public function getErrors()
2748
    {
2749
        return $this->errors;
2750
    }
2751
2752
    /**
2753
     * Includes missing or unsupported properties in stdClass
2754
     * Replace all unsuported chars
2755
     *
2756
     * @param  stdClass $std
2757
     * @param  array $possible
2758
     * @return stdClass
2759
     */
2760
    private function equilizeParameters(stdClass $std, $possible)
2761
    {
2762
        return Strings::equilizeParameters($std, $possible, $this->replaceAccentedChars);
0 ignored issues
show
Bug introduced by
The method equilizeParameters() does not seem to exist on object<NFePHP\Common\Strings>.

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

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

Loading history...
2763
    }
2764
}
2765