Completed
Push — master ( 8ed914...095f85 )
by Roberto
25:48 queued 11:05
created

EvtMovOpFinAnual::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 13
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 11
nc 1
nop 5
1
<?php
2
3
namespace NFePHP\eFinanc\Factories;
4
5
use NFePHP\eFinanc\Common\Factory;
6
use NFePHP\eFinanc\Common\FactoryInterface;
7
use NFePHP\eFinanc\Common\FactoryId;
8
use NFePHP\Common\Certificate;
9
use stdClass;
10
11
class EvtMovOpFinAnual extends Factory implements FactoryInterface
12
{
13
    /**
14
     * Constructor
15
     * @param string $config
16
     * @param stdClass $std
17
     * @param Certificate $certificate
18
     * @param string $data
19
     * @param string $version
20
     */
21
    public function __construct(
22
        $config,
23
        stdClass $std,
24
        Certificate $certificate = null,
25
        $data = '',
26
        $version = ''
27
    ) {
28
        $params = new \stdClass();
29
        $params->evtName = 'evtMovOpFinAnual';
30
        $params->evtTag = 'evtMovOpFinAnual';
31
        $params->evtAlias = 'F-3010';
32
        parent::__construct($config, $std, $params, $certificate, $data, $version);
33
    }
34
35
    protected function toNode()
36
    {
37
        $ideDeclarante = $this->node->getElementsByTagName('ideDeclarante')->item(0);
38
        //o idEvento pode variar de evento para evento
39
        //então cada factory individualmente terá de construir o seu
40
        $ideEvento = $this->dom->createElement("ideEvento");
41
        $this->dom->addChild(
42
            $ideEvento,
43
            "indRetificacao",
44
            $this->std->indretificacao,
45
            true
46
        );
47
        $this->dom->addChild(
48
            $ideEvento,
49
            "nrRecibo",
50
            isset($this->std->nrrecibo) ? $this->std->nrrecibo : null,
51
            false
52
        );
53
        $this->dom->addChild(
54
            $ideEvento,
55
            "tpAmb",
56
            (string) $this->tpAmb,
57
            true
58
        );
59
        $this->dom->addChild(
60
            $ideEvento,
61
            "aplicEmi",
62
            '1',
63
            true
64
        );
65
        $this->dom->addChild(
66
            $ideEvento,
67
            "verAplic",
68
            $this->verAplic,
69
            true
70
        );
71
        $this->node->insertBefore($ideEvento, $ideDeclarante);
72
        
73
        $ideDeclarado = $this->dom->createElement("ideDeclarado");
74
        $this->dom->addChild(
75
            $ideDeclarado,
76
            "tpNI",
77
            $this->std->tpni,
78
            true
79
        );
80
        $this->dom->addChild(
81
            $ideDeclarado,
82
            "tpDeclarado",
83
            !empty($this->std->tpdeclarado) ? $this->std->tpdeclarado : null,
84
            false
85
        );
86
        $this->dom->addChild(
87
            $ideDeclarado,
88
            "NIDeclarado",
89
            $this->std->nideclarado,
90
            true
91
        );
92
        
93 View Code Duplication
        if (!empty($this->std->nif)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
94
            foreach ($this->std->nif as $n) {
95
                $NIF = $this->dom->createElement("NIF");
96
                $this->dom->addChild(
97
                    $NIF,
98
                    "NumeroNIF",
99
                    $n->numeronif,
100
                    true
101
                );
102
                $this->dom->addChild(
103
                    $NIF,
104
                    "PaisEmissaoNIF",
105
                    $n->paisemissaonif,
106
                    true
107
                );
108
                $this->dom->addChild(
109
                    $NIF,
110
                    "tpNIF",
111
                    !empty($n->tpnif) ? $n->tpnif : null,
112
                    false
113
                );
114
                $ideDeclarado->appendChild($NIF);
115
            }
116
        }
117
        $this->dom->addChild(
118
            $ideDeclarado,
119
            "NomeDeclarado",
120
            $this->std->nomedeclarado,
121
            true
122
        );
123
        $this->dom->addChild(
124
            $ideDeclarado,
125
            "tpNomeDeclarado",
126
            !empty($this->std->tpnomedeclarado) ? $this->std->tpnomedeclarado : null,
127
            false
128
        );
129 View Code Duplication
        if ($this->std->nomeoutros) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
130
            foreach ($this->std->nomeoutros as $no) {
131
                $NomeOutros = $this->dom->createElement("NomeOutros");
132
                if (!empty($no->nomepf)) {
133
                    $npf = $no->nomepf;
134
                    $NomePF = $this->dom->createElement("NomePF");
135
                    $this->dom->addChild(
136
                        $NomePF,
137
                        "tpNome",
138
                        !empty($npf->tpnome) ? $npf->tpnome : null,
139
                        false
140
                    );
141
                    $this->dom->addChild(
142
                        $NomePF,
143
                        "PrecTitulo",
144
                        !empty($npf->prectitulo) ? $npf->prectitulo : null,
145
                        false
146
                    );
147
                    $this->dom->addChild(
148
                        $NomePF,
149
                        "Titulo",
150
                        !empty($npf->titulo) ? $npf->titulo : null,
151
                        false
152
                    );
153
                    $PrimeiroNome = $this->dom->createElement("PrimeiroNome");
154
                    $p = $npf->primeironome;
155
                    $this->dom->addChild(
156
                        $PrimeiroNome,
157
                        "Tipo",
158
                        !empty($p->tipo) ? $p->tipo : null,
159
                        false
160
                    );
161
                    $this->dom->addChild(
162
                        $PrimeiroNome,
163
                        "Nome",
164
                        $p->nome,
165
                        true
166
                    );
167
                    $NomePF->appendChild($PrimeiroNome);
168
                    if (!empty($npf->meionome)) {
169
                        foreach ($npf->meionome as $p) {
170
                            $MeioNome = $this->dom->createElement("MeioNome");
171
                            $this->dom->addChild(
172
                                $MeioNome,
173
                                "Tipo",
174
                                !empty($p->tipo) ? $p->tipo : null,
175
                                false
176
                            );
177
                            $this->dom->addChild(
178
                                $MeioNome,
179
                                "Nome",
180
                                $p->nome,
181
                                true
182
                            );
183
                            $NomePF->appendChild($MeioNome);
184
                        }
185
                    }
186
                    if (!empty($npf->prefixonome)) {
187
                        $p = $npf->prefixonome;
188
                        $PrefixoNome = $this->dom->createElement("PrefixoNome");
189
                        $this->dom->addChild(
190
                            $PrefixoNome,
191
                            "Tipo",
192
                            !empty($p->tipo) ? $p->tipo : null,
193
                            false
194
                        );
195
                        $this->dom->addChild(
196
                            $PrefixoNome,
197
                            "Nome",
198
                            $p->nome,
199
                            true
200
                        );
201
                        $NomePF->appendChild($PrefixoNome);
202
                    }
203
                    $UltimoNome = $this->dom->createElement("UltimoNome");
204
                    $p = $npf->ultimonome;
205
                    $this->dom->addChild(
206
                        $UltimoNome,
207
                        "Tipo",
208
                        !empty($p->tipo) ? $p->tipo : null,
209
                        false
210
                    );
211
                    $this->dom->addChild(
212
                        $UltimoNome,
213
                        "Nome",
214
                        $p->nome,
215
                        true
216
                    );
217
                    $NomePF->appendChild($UltimoNome);
218
                    $this->dom->addChild(
219
                        $NomePF,
220
                        "IdGeracao",
221
                        !empty($npf->idgeracao) ? $npf->idgeracao : null,
222
                        false
223
                    );
224
                    $this->dom->addChild(
225
                        $NomePF,
226
                        "Sufixo",
227
                        !empty($npf->sufixo) ? $npf->sufixo : null,
228
                        false
229
                    );
230
                    $this->dom->addChild(
231
                        $NomePF,
232
                        "GenSufixo",
233
                        !empty($npf->gensufixo) ? $npf->gensufixo : null,
234
                        false
235
                    );
236
                    $NomeOutros->appendChild($NomePF);
237
                }
238
                if (!empty($no->nomepj)) {
239
                    $npj = $no->nomepj;
240
                    $NomePJ = $this->dom->createElement("NomePJ");
241
                    $this->dom->addChild(
242
                        $NomePJ,
243
                        "tpNome",
244
                        !empty($npj->tpnome) ? $npj->tpnome : null,
245
                        false
246
                    );
247
                    $this->dom->addChild(
248
                        $NomePJ,
249
                        "Nome",
250
                        $npj->nome,
251
                        true
252
                    );
253
                    $NomeOutros->appendChild($NomePJ);
254
                }
255
                $ideDeclarado->appendChild($NomeOutros);
256
            }
257
        }
258
        
259
        $this->dom->addChild(
260
            $ideDeclarado,
261
            "DataNasc",
262
            !empty($this->std->datanasc) ? $this->std->datanasc : null,
263
            false
264
        );
265
        
266 View Code Duplication
        if (!empty($this->std->infonascimento)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
267
            $in = $this->std->infonascimento;
268
            $InfoNascimento = $this->dom->createElement("InfoNascimento");
269
            $this->dom->addChild(
270
                $InfoNascimento,
271
                "Municipio",
272
                !empty($in->municipio) ? $in->municipio : null,
273
                false
274
            );
275
            $this->dom->addChild(
276
                $InfoNascimento,
277
                "Bairro",
278
                !empty($in->bairro) ? $in->bairro : null,
279
                false
280
            );
281
            if (!empty($in->pais)) {
282
                $PaisNasc = $this->dom->createElement("PaisNasc");
283
                $this->dom->addChild(
284
                    $PaisNasc,
285
                    "Pais",
286
                    $in->pais,
287
                    false
288
                );
289
                $InfoNascimento->appendChild($PaisNasc);
290
            } elseif (!empty($in->antigonomepais)) {
291
                $PaisNasc = $this->dom->createElement("PaisNasc");
292
                $this->dom->addChild(
293
                    $PaisNasc,
294
                    "AntigoNomePais",
295
                    $in->antigonomepais,
296
                    false
297
                );
298
                $InfoNascimento->appendChild($PaisNasc);
299
            }
300
            $ideDeclarado->appendChild($InfoNascimento);
301
        }
302
        $this->dom->addChild(
303
            $ideDeclarado,
304
            "EnderecoLivre",
305
            !empty($this->std->enderecolivre) ? $this->std->enderecolivre : null,
306
            false
307
        );
308
        $this->dom->addChild(
309
            $ideDeclarado,
310
            "tpEndereco",
311
            !empty($this->std->tpendereco) ? $this->std->tpendereco : null,
312
            false
313
        );
314
        $PaisEndereco = $this->dom->createElement("PaisEndereco");
315
        $this->dom->addChild(
316
            $PaisEndereco,
317
            "Pais",
318
            $this->std->pais,
319
            true
320
        );
321
        $ideDeclarado->appendChild($PaisEndereco);
322
        
323 View Code Duplication
        if (!empty($this->std->enderecooutros)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
324
            foreach ($this->std->enderecooutros as $eo) {
325
                $EnderecoOutros = $this->dom->createElement("EnderecoOutros");
326
                $this->dom->addChild(
327
                    $EnderecoOutros,
328
                    "tpEndereco",
329
                    !empty($eo->tpendereco) ? $eo->tpendereco : null,
330
                    false
331
                );
332
                $this->dom->addChild(
333
                    $EnderecoOutros,
334
                    "EnderecoLivre",
335
                    !empty($eo->enderecolivre) ? $eo->enderecolivre : null,
336
                    false
337
                );
338
                if (!empty($eo->enderecoestrutura) && empty($eo->enderecolivre)) {
339
                    $ee = $eo->enderecoestrutura;
340
                    $EnderecoEstrutura = $this->dom->createElement("EnderecoEstrutura");
341
                    $this->dom->addChild(
342
                        $EnderecoEstrutura,
343
                        "EnderecoLivre",
344
                        !empty($ee->enderecolivre) ? $ee->enderecolivre : null,
345
                        false
346
                    );
347
                    if (!empty($ee->endereco)) {
348
                        $end = $ee->endereco;
349
                        $Endereco = $this->dom->createElement("Endereco");
350
                        $this->dom->addChild(
351
                            $Endereco,
352
                            "Logradouro",
353
                            !empty($end->logradouro) ? $end->logradouro : null,
354
                            false
355
                        );
356
                        $this->dom->addChild(
357
                            $Endereco,
358
                            "Numero",
359
                            !empty($end->numero) ? $end->numero : null,
360
                            false
361
                        );
362
                        $this->dom->addChild(
363
                            $Endereco,
364
                            "Complemento",
365
                            !empty($end->complemento) ? $end->complemento : null,
366
                            false
367
                        );
368
                        $this->dom->addChild(
369
                            $Endereco,
370
                            "Andar",
371
                            !empty($end->andar) ? $end->andar : null,
372
                            false
373
                        );
374
                        $this->dom->addChild(
375
                            $Endereco,
376
                            "Bairro",
377
                            !empty($end->bairro) ? $end->bairro : null,
378
                            false
379
                        );
380
                        $this->dom->addChild(
381
                            $Endereco,
382
                            "CaixaPostal",
383
                            !empty($end->caixapostal) ? $end->caixapostal : null,
384
                            false
385
                        );
386
                        $EnderecoEstrutura->appendChild($Endereco);
387
                    }
388
                    $this->dom->addChild(
389
                        $EnderecoEstrutura,
390
                        "CEP",
391
                        $ee->cep,
392
                        true
393
                    );
394
                    $this->dom->addChild(
395
                        $EnderecoEstrutura,
396
                        "Municipio",
397
                        $ee->municipio,
398
                        true
399
                    );
400
                    $this->dom->addChild(
401
                        $EnderecoEstrutura,
402
                        "UF",
403
                        $ee->uf,
404
                        true
405
                    );
406
                    $EnderecoOutros->appendChild($EnderecoEstrutura);
407
                }
408
                $this->dom->addChild(
409
                    $EnderecoOutros,
410
                    "Pais",
411
                    $eo->pais,
412
                    true
413
                );
414
415
                $ideDeclarado->appendChild($EnderecoOutros);
416
            }
417
        }
418 View Code Duplication
        if (!empty($this->std->paisresid)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
419
            foreach ($this->std->paisresid as $pr) {
420
                $paisResid = $this->dom->createElement("paisResid");
421
                $this->dom->addChild(
422
                    $paisResid,
423
                    "Pais",
424
                    $pr->pais,
425
                    true
426
                );
427
                $ideDeclarado->appendChild($paisResid);
428
            }
429
        }
430 View Code Duplication
        if (!empty($this->std->paisnacionalidade)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
431
            foreach ($this->std->paisnacionalidade as $pr) {
432
                $PaisNacionalidade = $this->dom->createElement("PaisNacionalidade");
433
                $this->dom->addChild(
434
                    $PaisNacionalidade,
435
                    "Pais",
436
                    $pr->pais,
437
                    true
438
                );
439
                $ideDeclarado->appendChild($PaisNacionalidade);
440
            }
441
        }
442
        if (!empty($this->std->proprietarios)) {
443
            foreach ($this->std->proprietarios as $p) {
444
                $Proprietarios = $this->dom->createElement("Proprietarios");
445
                $this->dom->addChild(
446
                    $Proprietarios,
447
                    "tpNI",
448
                    $p->tpni,
449
                    true
450
                );
451
                $this->dom->addChild(
452
                    $Proprietarios,
453
                    "NIProprietario",
454
                    $p->niproprietario,
455
                    true
456
                );
457
                $this->dom->addChild(
458
                    $Proprietarios,
459
                    "tpProprietario",
460
                    !empty($p->tpproprietario) ? $p->tpproprietario : null,
461
                    false
462
                );
463
                if (!empty($p->nif)) {
464
                    foreach ($p->nif as $n) {
465
                        $NIF = $this->dom->createElement("NIF");
466
                        $this->dom->addChild(
467
                            $NIF,
468
                            "NumeroNIF",
469
                            $n->numeronif,
470
                            true
471
                        );
472
                        $this->dom->addChild(
473
                            $NIF,
474
                            "PaisEmissaoNIF",
475
                            $n->paisemissaonif,
476
                            true
477
                        );
478
                        $Proprietarios->appendChild($NIF);
479
                    }
480
                }
481
                $this->dom->addChild(
482
                    $Proprietarios,
483
                    "Nome",
484
                    $p->nome,
485
                    true
486
                );
487
                $this->dom->addChild(
488
                    $Proprietarios,
489
                    "tpNome",
490
                    !empty($p->tpnome) ? $p->tpnome : null,
491
                    false
492
                );
493
                
494 View Code Duplication
                if (!empty($p->nomeoutros)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
495
                    foreach ($p->nomeoutros as $no) {
496
                        $NomeOutros = $this->dom->createElement("NomeOutros");
497
                        $npf = $no->nomepf;
498
                        $NomePF = $this->dom->createElement("NomePF");
499
                        $this->dom->addChild(
500
                            $NomePF,
501
                            "tpNome",
502
                            !empty($npf->tpnome) ? $npf->tpnome : null,
503
                            false
504
                        );
505
                        $this->dom->addChild(
506
                            $NomePF,
507
                            "PrecTitulo",
508
                            !empty($npf->prectitulo) ? $npf->prectitulo : null,
509
                            false
510
                        );
511
                        $this->dom->addChild(
512
                            $NomePF,
513
                            "Titulo",
514
                            !empty($npf->titulo) ? $npf->titulo : null,
515
                            false
516
                        );
517
                        $PrimeiroNome = $this->dom->createElement("PrimeiroNome");
518
                            $pn = $npf->primeironome;
519
                            $this->dom->addChild(
520
                                $PrimeiroNome,
521
                                "Tipo",
522
                                !empty($pn->tipo) ? $pn->tipo : null,
523
                                false
524
                            );
525
                            $this->dom->addChild(
526
                                $PrimeiroNome,
527
                                "Nome",
528
                                $pn->nome,
529
                                true
530
                            );
531
                            $NomePF->appendChild($PrimeiroNome);
532
                        if (!empty($npf->meionome)) {
533
                            foreach ($npf->meionome as $pn) {
534
                                $MeioNome = $this->dom->createElement("MeioNome");
535
                                $this->dom->addChild(
536
                                    $MeioNome,
537
                                    "Tipo",
538
                                    !empty($pn->tipo) ? $pn->tipo : null,
539
                                    false
540
                                );
541
                                $this->dom->addChild(
542
                                    $MeioNome,
543
                                    "Nome",
544
                                    $pn->nome,
545
                                    true
546
                                );
547
                                $NomePF->appendChild($MeioNome);
548
                            }
549
                        }
550
                        if (!empty($npf->prefixonome)) {
551
                            $pn = $npf->prefixonome;
552
                            $PrefixoNome = $this->dom->createElement("PrefixoNome");
553
                            $this->dom->addChild(
554
                                $PrefixoNome,
555
                                "Tipo",
556
                                !empty($pn->tipo) ? $pn->tipo : null,
557
                                false
558
                            );
559
                            $this->dom->addChild(
560
                                $PrefixoNome,
561
                                "Nome",
562
                                $pn->nome,
563
                                true
564
                            );
565
                            $NomePF->appendChild($PrefixoNome);
566
                        }
567
                        $UltimoNome = $this->dom->createElement("UltimoNome");
568
                        $pn = $npf->ultimonome;
569
                        $this->dom->addChild(
570
                            $UltimoNome,
571
                            "Tipo",
572
                            !empty($pn->tipo) ? $pn->tipo : null,
573
                            false
574
                        );
575
                        $this->dom->addChild(
576
                            $UltimoNome,
577
                            "Nome",
578
                            $pn->nome,
579
                            true
580
                        );
581
                        $NomePF->appendChild($UltimoNome);
582
                        $NomeOutros->appendChild($NomePF);
583
                        $Proprietarios->appendChild($NomeOutros);
584
                    }
585
                }
586
                $this->dom->addChild(
587
                    $Proprietarios,
588
                    "EnderecoLivre",
589
                    $p->enderecolivre,
590
                    true
591
                );
592
                $this->dom->addChild(
593
                    $Proprietarios,
594
                    "tpEndereco",
595
                    !empty($p->tpendereco) ? $p->tpendereco : null,
596
                    false
597
                );
598
                $PaisEndereco = $this->dom->createElement("PaisEndereco");
599
                $this->dom->addChild(
600
                    $PaisEndereco,
601
                    "Pais",
602
                    $p->pais,
603
                    true
604
                );
605
                $Proprietarios->appendChild($PaisEndereco);
606
                
607 View Code Duplication
                if (!empty($p->enderecooutros)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
608
                    foreach ($p->enderecooutros as $eo) {
609
                        $EnderecoOutros = $this->dom->createElement("EnderecoOutros");
610
                        $this->dom->addChild(
611
                            $EnderecoOutros,
612
                            "tpEndereco",
613
                            !empty($eo->tpendereco) ? $eo->tpendereco : null,
614
                            false
615
                        );
616
                        $this->dom->addChild(
617
                            $EnderecoOutros,
618
                            "EnderecoLivre",
619
                            !empty($eo->enderecolivre) ? $eo->enderecolivre : null,
620
                            false
621
                        );
622
                        if (!empty($eo->enderecoestrutura) && empty($eo->enderecolivre)) {
623
                            $ee = $eo->enderecoestrutura;
624
                            $EnderecoEstrutura = $this->dom->createElement("EnderecoEstrutura");
625
                            $this->dom->addChild(
626
                                $EnderecoEstrutura,
627
                                "EnderecoLivre",
628
                                !empty($ee->enderecolivre) ? $ee->enderecolivre : null,
629
                                false
630
                            );
631
                            if (!empty($ee->endereco)) {
632
                                $end = $ee->endereco;
633
                                $Endereco = $this->dom->createElement("Endereco");
634
                                $this->dom->addChild(
635
                                    $Endereco,
636
                                    "Logradouro",
637
                                    !empty($end->logradouro) ? $end->logradouro : null,
638
                                    false
639
                                );
640
                                $this->dom->addChild(
641
                                    $Endereco,
642
                                    "Numero",
643
                                    !empty($end->numero) ? $end->numero : null,
644
                                    false
645
                                );
646
                                $this->dom->addChild(
647
                                    $Endereco,
648
                                    "Complemento",
649
                                    !empty($end->complemento) ? $end->complemento : null,
650
                                    false
651
                                );
652
                                $this->dom->addChild(
653
                                    $Endereco,
654
                                    "Andar",
655
                                    !empty($end->andar) ? $end->andar : null,
656
                                    false
657
                                );
658
                                $this->dom->addChild(
659
                                    $Endereco,
660
                                    "Bairro",
661
                                    !empty($end->bairro) ? $end->bairro : null,
662
                                    false
663
                                );
664
                                $this->dom->addChild(
665
                                    $Endereco,
666
                                    "CaixaPostal",
667
                                    !empty($end->caixapostal) ? $end->caixapostal : null,
668
                                    false
669
                                );
670
                                $EnderecoEstrutura->appendChild($Endereco);
671
                            }
672
                            $this->dom->addChild(
673
                                $EnderecoEstrutura,
674
                                "CEP",
675
                                $ee->cep,
676
                                true
677
                            );
678
                            $this->dom->addChild(
679
                                $EnderecoEstrutura,
680
                                "Municipio",
681
                                $ee->municipio,
682
                                true
683
                            );
684
                            $this->dom->addChild(
685
                                $EnderecoEstrutura,
686
                                "UF",
687
                                $ee->uf,
688
                                true
689
                            );
690
                            $EnderecoOutros->appendChild($EnderecoEstrutura);
691
                        }
692
                        $this->dom->addChild(
693
                            $EnderecoOutros,
694
                            "Pais",
695
                            $eo->pais,
696
                            true
697
                        );
698
                        $Proprietarios->appendChild($EnderecoOutros);
699
                    }
700
                }
701
                
702 View Code Duplication
                if (!empty($p->paisresid)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
703
                    foreach ($p->paisresid as $pr) {
704
                        $paisResid = $this->dom->createElement("paisResid");
705
                        $this->dom->addChild(
706
                            $paisResid,
707
                            "Pais",
708
                            $pr->pais,
709
                            true
710
                        );
711
                        $Proprietarios->appendChild($paisResid);
712
                    }
713
                }
714 View Code Duplication
                if (!empty($p->paisnacionalidade)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
715
                    foreach ($p->paisnacionalidade as $pr) {
716
                        $PaisNacionalidade = $this->dom->createElement("PaisNacionalidade");
717
                        $this->dom->addChild(
718
                            $PaisNacionalidade,
719
                            "Pais",
720
                            $pr->pais,
721
                            true
722
                        );
723
                        $Proprietarios->appendChild($PaisNacionalidade);
724
                    }
725
                }
726
                
727
                $this->dom->addChild(
728
                    $Proprietarios,
729
                    "DataNasc",
730
                    !empty($p->datanasc) ? $p->datanasc : null,
731
                    false
732
                );
733
                
734 View Code Duplication
                if (!empty($p->infonascimento)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
735
                    $in = $p->infonascimento;
736
                    $InfoNascimento = $this->dom->createElement("InfoNascimento");
737
                    $this->dom->addChild(
738
                        $InfoNascimento,
739
                        "Municipio",
740
                        !empty($in->municipio) ? $in->municipio : null,
741
                        false
742
                    );
743
                    $this->dom->addChild(
744
                        $InfoNascimento,
745
                        "Bairro",
746
                        !empty($in->bairro) ? $in->bairro : null,
747
                        false
748
                    );
749
                    if (!empty($in->pais)) {
750
                        $PaisNasc = $this->dom->createElement("PaisNasc");
751
                        $this->dom->addChild(
752
                            $PaisNasc,
753
                            "Pais",
754
                            $in->pais,
755
                            false
756
                        );
757
                        $InfoNascimento->appendChild($PaisNasc);
758
                    } elseif (!empty($in->antigonomepais)) {
759
                        $PaisNasc = $this->dom->createElement("PaisNasc");
760
                        $this->dom->addChild(
761
                            $PaisNasc,
762
                            "AntigoNomePais",
763
                            $in->antigonomepais,
764
                            false
765
                        );
766
                        $InfoNascimento->appendChild($PaisNasc);
767
                    }
768
                    $Proprietarios->appendChild($InfoNascimento);
769
                }
770
                
771
                
772 View Code Duplication
                foreach ($p->reportavel as $r) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
773
                    $Reportavel = $this->dom->createElement("Reportavel");
774
                    $this->dom->addChild(
775
                        $Reportavel,
776
                        "Pais",
777
                        $r->pais,
778
                        true
779
                    );
780
                    $Proprietarios->appendChild($Reportavel);
781
                }
782
                $ideDeclarado->appendChild($Proprietarios);
783
            }
784
        }
785
        $this->node->appendChild($ideDeclarado);
786
        
787
        $caixa = $this->dom->createElement("Caixa");
788
        $this->dom->addChild(
789
            $caixa,
790
            "anoCaixa",
791
            $this->std->anocaixa,
792
            true
793
        );
794
        $this->dom->addChild(
795
            $caixa,
796
            "semestre",
797
            $this->std->semestre,
798
            true
799
        );
800
        
801
        $movOpFin = $this->dom->createElement("movOpFinAnual");
802
        
803
        
804
805
        
806
        if (!empty($this->std->conta)) {
807
            foreach ($this->std->conta as $c) {
808
                $Conta = $this->dom->createElement("Conta");
809 View Code Duplication
                if (!empty($c->medjudic)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
810
                    foreach ($c->medjudic as $j) {
811
                        $MedJudic = $this->dom->createElement("MedJudic");
812
                        $this->dom->addChild(
813
                            $MedJudic,
814
                            "NumProcJud",
815
                            $j->numprocjud,
816
                            true
817
                        );
818
                        $this->dom->addChild(
819
                            $MedJudic,
820
                            "Vara",
821
                            $j->vara,
822
                            true
823
                        );
824
                        $this->dom->addChild(
825
                            $MedJudic,
826
                            "SecJud",
827
                            $j->secjud,
828
                            true
829
                        );
830
                        $this->dom->addChild(
831
                            $MedJudic,
832
                            "SubSecJud",
833
                            $j->subsecjud,
834
                            true
835
                        );
836
                        $this->dom->addChild(
837
                            $MedJudic,
838
                            "dtConcessao",
839
                            $j->dtconcessao,
840
                            true
841
                        );
842
                        $this->dom->addChild(
843
                            $MedJudic,
844
                            "dtCassacao",
845
                            !empty($j->dtcassacao) ? $j->dtcassacao : null,
846
                            false
847
                        );
848
                        $Conta->appendChild($MedJudic);
849
                    }
850
                }
851
                
852
                if (!empty($c->infoconta)) {
853
                    $ic = $c->infoconta;
854
                    $infoConta = $this->dom->createElement("infoConta");
855 View Code Duplication
                    foreach ($ic->reportavel as $r) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
856
                        $Reportavel = $this->dom->createElement("Reportavel");
857
                        $this->dom->addChild(
858
                            $Reportavel,
859
                            "Pais",
860
                            $r->pais,
861
                            true
862
                        );
863
                        $infoConta->appendChild($Reportavel);
864
                    }
865
                    $this->dom->addChild(
866
                        $infoConta,
867
                        "tpConta",
868
                        $ic->tpconta,
869
                        true
870
                    );
871
                    $this->dom->addChild(
872
                        $infoConta,
873
                        "subTpConta",
874
                        $ic->subtpconta,
875
                        true
876
                    );
877
                    $this->dom->addChild(
878
                        $infoConta,
879
                        "tpNumConta",
880
                        $ic->tpnumconta,
881
                        true
882
                    );
883
                    $this->dom->addChild(
884
                        $infoConta,
885
                        "numConta",
886
                        $ic->numconta,
887
                        true
888
                    );
889
                    $this->dom->addChild(
890
                        $infoConta,
891
                        "tpRelacaoDeclarado",
892
                        $ic->tprelacaodeclarado,
893
                        true
894
                    );
895
896 View Code Duplication
                    if (!empty($ic->intermediario)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
897
                        $i = $ic->intermediario;
898
                        $Intermediario = $this->dom->createElement("Intermediario");
899
                        $this->dom->addChild(
900
                            $Intermediario,
901
                            "GIIN",
902
                            !empty($i->giin) ? $i->giin : null,
903
                            false
904
                        );
905
                        $this->dom->addChild(
906
                            $Intermediario,
907
                            "tpNI",
908
                            !empty($i->tpni) ? $i->tpni : null,
909
                            false
910
                        );
911
                        $this->dom->addChild(
912
                            $Intermediario,
913
                            "NIIntermediario",
914
                            !empty($i->niintermediario) ? $i->niintermediario : null,
915
                            false
916
                        );
917
                        $infoConta->appendChild($Intermediario);
918
                    }
919
                    $this->dom->addChild(
920
                        $infoConta,
921
                        "NoTitulares",
922
                        !empty($ic->notitulares) ? $ic->notitulares : null,
923
                        false
924
                    );
925
                    $this->dom->addChild(
926
                        $infoConta,
927
                        "dtEncerramentoConta",
928
                        !empty($ic->dtencerramentoconta) ? $ic->dtencerramentoconta : null,
929
                        false
930
                    );
931
                    $this->dom->addChild(
932
                        $infoConta,
933
                        "IndInatividade",
934
                        !empty($ic->indinatividade) ? $ic->indinatividade : null,
935
                        false
936
                    );
937
                    $this->dom->addChild(
938
                        $infoConta,
939
                        "IndNDoc",
940
                        !empty($ic->indndoc) ? $ic->indndoc : null,
941
                        false
942
                    );
943 View Code Duplication
                    if (!empty($ic->fundo)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
944
                        $f = $ic->fundo;
945
                        $Fundo = $this->dom->createElement("Fundo");
946
                        $this->dom->addChild(
947
                            $Fundo,
948
                            "GIIN",
949
                            !empty($f->giin) ? $f->giin : null,
950
                            false
951
                        );
952
                        $this->dom->addChild(
953
                            $Fundo,
954
                            "CNPJ",
955
                            $f->cnpj,
956
                            true
957
                        );
958
                        $infoConta->appendChild($Fundo);
959
                    }
960
                    
961
                    $BalancoConta = $this->dom->createElement("BalancoConta");
962
                    $this->dom->addChild(
963
                        $BalancoConta,
964
                        "vlrUltDia",
965
                        !empty($ic->vlrultdia) ? number_format($ic->vlrultdia, 2, ',', '') : null,
966
                        false
967
                    );
968
                    $infoConta->appendChild($BalancoConta);
969
                    
970 View Code Duplication
                    foreach ($ic->pgtosacum as $pg) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
971
                        $PgtosAcum = $this->dom->createElement("PgtosAcum");
972
                        $this->dom->addChild(
973
                            $PgtosAcum,
974
                            "tpPgto",
975
                            $pg->tppgto,
976
                            true
977
                        );
978
                        $this->dom->addChild(
979
                            $PgtosAcum,
980
                            "totPgtosAcum",
981
                            number_format($pg->totpgtosacum, 2, ',', ''),
982
                            true
983
                        );
984
                        $infoConta->appendChild($PgtosAcum);
985
                    }
986
                    $Conta->appendChild($infoConta);
987
                }
988
                $movOpFin->appendChild($Conta);
989
            }
990
        }
991
        
992
        $caixa->appendChild($movOpFin);
993
        $this->node->appendChild($caixa);
994
                
995
        //finalização do xml
996
        $this->eFinanceira->appendChild($this->node);
997
        //$this->xml = $this->dom->saveXML($this->eFinanceira);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
998
        $this->sign($this->evtTag);
999
    }
1000
}
1001