EvtMovOpFinAnual   F
last analyzed

Complexity

Total Complexity 115

Size/Duplication

Total Lines 988
Duplicated Lines 68.02 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 115
c 0
b 0
f 0
lcom 1
cbo 1
dl 672
loc 988
rs 1.612

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
F toNode() 672 965 114

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like EvtMovOpFinAnual often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use EvtMovOpFinAnual, and based on these observations, apply Extract Interface, too.

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
     */
20
    public function __construct(
21
        $config,
22
        stdClass $std,
23
        Certificate $certificate = null,
24
        $data = ''
25
    ) {
26
        $params = new \stdClass();
27
        $params->evtName = 'evtMovOpFinAnual';
28
        $params->evtTag = 'evtMovOpFinAnual';
29
        $params->evtAlias = 'F-3010';
30
        parent::__construct($config, $std, $params, $certificate, $data);
31
    }
32
33
    protected function toNode()
34
    {
35
        $ideDeclarante = $this->node->getElementsByTagName('ideDeclarante')->item(0);
36
        //o idEvento pode variar de evento para evento
37
        //então cada factory individualmente terá de construir o seu
38
        $ideEvento = $this->dom->createElement("ideEvento");
39
        $this->dom->addChild(
40
            $ideEvento,
41
            "indRetificacao",
42
            $this->std->indretificacao,
43
            true
44
        );
45
        $this->dom->addChild(
46
            $ideEvento,
47
            "nrRecibo",
48
            isset($this->std->nrrecibo) ? $this->std->nrrecibo : null,
49
            false
50
        );
51
        $this->dom->addChild(
52
            $ideEvento,
53
            "tpAmb",
54
            (string) $this->tpAmb,
55
            true
56
        );
57
        $this->dom->addChild(
58
            $ideEvento,
59
            "aplicEmi",
60
            '1',
61
            true
62
        );
63
        $this->dom->addChild(
64
            $ideEvento,
65
            "verAplic",
66
            $this->verAplic,
67
            true
68
        );
69
        $this->node->insertBefore($ideEvento, $ideDeclarante);
70
        
71
        $ideDeclarado = $this->dom->createElement("ideDeclarado");
72
        $this->dom->addChild(
73
            $ideDeclarado,
74
            "tpNI",
75
            $this->std->tpni,
76
            true
77
        );
78
        $this->dom->addChild(
79
            $ideDeclarado,
80
            "tpDeclarado",
81
            !empty($this->std->tpdeclarado) ? $this->std->tpdeclarado : null,
82
            false
83
        );
84
        $this->dom->addChild(
85
            $ideDeclarado,
86
            "NIDeclarado",
87
            $this->std->nideclarado,
88
            true
89
        );
90
        
91 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...
92
            foreach ($this->std->nif as $n) {
93
                $NIF = $this->dom->createElement("NIF");
94
                $this->dom->addChild(
95
                    $NIF,
96
                    "NumeroNIF",
97
                    $n->numeronif,
98
                    true
99
                );
100
                $this->dom->addChild(
101
                    $NIF,
102
                    "PaisEmissaoNIF",
103
                    $n->paisemissaonif,
104
                    true
105
                );
106
                $this->dom->addChild(
107
                    $NIF,
108
                    "tpNIF",
109
                    !empty($n->tpnif) ? $n->tpnif : null,
110
                    false
111
                );
112
                $ideDeclarado->appendChild($NIF);
113
            }
114
        }
115
        $this->dom->addChild(
116
            $ideDeclarado,
117
            "NomeDeclarado",
118
            $this->std->nomedeclarado,
119
            true
120
        );
121
        $this->dom->addChild(
122
            $ideDeclarado,
123
            "tpNomeDeclarado",
124
            !empty($this->std->tpnomedeclarado) ? $this->std->tpnomedeclarado : null,
125
            false
126
        );
127 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...
128
            foreach ($this->std->nomeoutros as $no) {
129
                $NomeOutros = $this->dom->createElement("NomeOutros");
130
                if (!empty($no->nomepf)) {
131
                    $npf = $no->nomepf;
132
                    $NomePF = $this->dom->createElement("NomePF");
133
                    $this->dom->addChild(
134
                        $NomePF,
135
                        "tpNome",
136
                        !empty($npf->tpnome) ? $npf->tpnome : null,
137
                        false
138
                    );
139
                    $this->dom->addChild(
140
                        $NomePF,
141
                        "PrecTitulo",
142
                        !empty($npf->prectitulo) ? $npf->prectitulo : null,
143
                        false
144
                    );
145
                    $this->dom->addChild(
146
                        $NomePF,
147
                        "Titulo",
148
                        !empty($npf->titulo) ? $npf->titulo : null,
149
                        false
150
                    );
151
                    $PrimeiroNome = $this->dom->createElement("PrimeiroNome");
152
                    $p = $npf->primeironome;
153
                    $this->dom->addChild(
154
                        $PrimeiroNome,
155
                        "Tipo",
156
                        !empty($p->tipo) ? $p->tipo : null,
157
                        false
158
                    );
159
                    $this->dom->addChild(
160
                        $PrimeiroNome,
161
                        "Nome",
162
                        $p->nome,
163
                        true
164
                    );
165
                    $NomePF->appendChild($PrimeiroNome);
166
                    if (!empty($npf->meionome)) {
167
                        foreach ($npf->meionome as $p) {
168
                            $MeioNome = $this->dom->createElement("MeioNome");
169
                            $this->dom->addChild(
170
                                $MeioNome,
171
                                "Tipo",
172
                                !empty($p->tipo) ? $p->tipo : null,
173
                                false
174
                            );
175
                            $this->dom->addChild(
176
                                $MeioNome,
177
                                "Nome",
178
                                $p->nome,
179
                                true
180
                            );
181
                            $NomePF->appendChild($MeioNome);
182
                        }
183
                    }
184
                    if (!empty($npf->prefixonome)) {
185
                        $p = $npf->prefixonome;
186
                        $PrefixoNome = $this->dom->createElement("PrefixoNome");
187
                        $this->dom->addChild(
188
                            $PrefixoNome,
189
                            "Tipo",
190
                            !empty($p->tipo) ? $p->tipo : null,
191
                            false
192
                        );
193
                        $this->dom->addChild(
194
                            $PrefixoNome,
195
                            "Nome",
196
                            $p->nome,
197
                            true
198
                        );
199
                        $NomePF->appendChild($PrefixoNome);
200
                    }
201
                    $UltimoNome = $this->dom->createElement("UltimoNome");
202
                    $p = $npf->ultimonome;
203
                    $this->dom->addChild(
204
                        $UltimoNome,
205
                        "Tipo",
206
                        !empty($p->tipo) ? $p->tipo : null,
207
                        false
208
                    );
209
                    $this->dom->addChild(
210
                        $UltimoNome,
211
                        "Nome",
212
                        $p->nome,
213
                        true
214
                    );
215
                    $NomePF->appendChild($UltimoNome);
216
                    $this->dom->addChild(
217
                        $NomePF,
218
                        "IdGeracao",
219
                        !empty($npf->idgeracao) ? $npf->idgeracao : null,
220
                        false
221
                    );
222
                    $this->dom->addChild(
223
                        $NomePF,
224
                        "Sufixo",
225
                        !empty($npf->sufixo) ? $npf->sufixo : null,
226
                        false
227
                    );
228
                    $this->dom->addChild(
229
                        $NomePF,
230
                        "GenSufixo",
231
                        !empty($npf->gensufixo) ? $npf->gensufixo : null,
232
                        false
233
                    );
234
                    $NomeOutros->appendChild($NomePF);
235
                }
236
                if (!empty($no->nomepj)) {
237
                    $npj = $no->nomepj;
238
                    $NomePJ = $this->dom->createElement("NomePJ");
239
                    $this->dom->addChild(
240
                        $NomePJ,
241
                        "tpNome",
242
                        !empty($npj->tpnome) ? $npj->tpnome : null,
243
                        false
244
                    );
245
                    $this->dom->addChild(
246
                        $NomePJ,
247
                        "Nome",
248
                        $npj->nome,
249
                        true
250
                    );
251
                    $NomeOutros->appendChild($NomePJ);
252
                }
253
                $ideDeclarado->appendChild($NomeOutros);
254
            }
255
        }
256
        
257
        $this->dom->addChild(
258
            $ideDeclarado,
259
            "DataNasc",
260
            !empty($this->std->datanasc) ? $this->std->datanasc : null,
261
            false
262
        );
263
        
264 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...
265
            $in = $this->std->infonascimento;
266
            $InfoNascimento = $this->dom->createElement("InfoNascimento");
267
            $this->dom->addChild(
268
                $InfoNascimento,
269
                "Municipio",
270
                !empty($in->municipio) ? $in->municipio : null,
271
                false
272
            );
273
            $this->dom->addChild(
274
                $InfoNascimento,
275
                "Bairro",
276
                !empty($in->bairro) ? $in->bairro : null,
277
                false
278
            );
279
            if (!empty($in->pais)) {
280
                $PaisNasc = $this->dom->createElement("PaisNasc");
281
                $this->dom->addChild(
282
                    $PaisNasc,
283
                    "Pais",
284
                    $in->pais,
285
                    false
286
                );
287
                $InfoNascimento->appendChild($PaisNasc);
288
            } elseif (!empty($in->antigonomepais)) {
289
                $PaisNasc = $this->dom->createElement("PaisNasc");
290
                $this->dom->addChild(
291
                    $PaisNasc,
292
                    "AntigoNomePais",
293
                    $in->antigonomepais,
294
                    false
295
                );
296
                $InfoNascimento->appendChild($PaisNasc);
297
            }
298
            $ideDeclarado->appendChild($InfoNascimento);
299
        }
300
        $this->dom->addChild(
301
            $ideDeclarado,
302
            "EnderecoLivre",
303
            !empty($this->std->enderecolivre) ? $this->std->enderecolivre : null,
304
            false
305
        );
306
        $this->dom->addChild(
307
            $ideDeclarado,
308
            "tpEndereco",
309
            !empty($this->std->tpendereco) ? $this->std->tpendereco : null,
310
            false
311
        );
312
        $PaisEndereco = $this->dom->createElement("PaisEndereco");
313
        $this->dom->addChild(
314
            $PaisEndereco,
315
            "Pais",
316
            $this->std->pais,
317
            true
318
        );
319
        $ideDeclarado->appendChild($PaisEndereco);
320
        
321 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...
322
            foreach ($this->std->enderecooutros as $eo) {
323
                $EnderecoOutros = $this->dom->createElement("EnderecoOutros");
324
                $this->dom->addChild(
325
                    $EnderecoOutros,
326
                    "tpEndereco",
327
                    !empty($eo->tpendereco) ? $eo->tpendereco : null,
328
                    false
329
                );
330
                $this->dom->addChild(
331
                    $EnderecoOutros,
332
                    "EnderecoLivre",
333
                    !empty($eo->enderecolivre) ? $eo->enderecolivre : null,
334
                    false
335
                );
336
                if (!empty($eo->enderecoestrutura) && empty($eo->enderecolivre)) {
337
                    $ee = $eo->enderecoestrutura;
338
                    $EnderecoEstrutura = $this->dom->createElement("EnderecoEstrutura");
339
                    $this->dom->addChild(
340
                        $EnderecoEstrutura,
341
                        "EnderecoLivre",
342
                        !empty($ee->enderecolivre) ? $ee->enderecolivre : null,
343
                        false
344
                    );
345
                    if (!empty($ee->endereco)) {
346
                        $end = $ee->endereco;
347
                        $Endereco = $this->dom->createElement("Endereco");
348
                        $this->dom->addChild(
349
                            $Endereco,
350
                            "Logradouro",
351
                            !empty($end->logradouro) ? $end->logradouro : null,
352
                            false
353
                        );
354
                        $this->dom->addChild(
355
                            $Endereco,
356
                            "Numero",
357
                            !empty($end->numero) ? $end->numero : null,
358
                            false
359
                        );
360
                        $this->dom->addChild(
361
                            $Endereco,
362
                            "Complemento",
363
                            !empty($end->complemento) ? $end->complemento : null,
364
                            false
365
                        );
366
                        $this->dom->addChild(
367
                            $Endereco,
368
                            "Andar",
369
                            !empty($end->andar) ? $end->andar : null,
370
                            false
371
                        );
372
                        $this->dom->addChild(
373
                            $Endereco,
374
                            "Bairro",
375
                            !empty($end->bairro) ? $end->bairro : null,
376
                            false
377
                        );
378
                        $this->dom->addChild(
379
                            $Endereco,
380
                            "CaixaPostal",
381
                            !empty($end->caixapostal) ? $end->caixapostal : null,
382
                            false
383
                        );
384
                        $EnderecoEstrutura->appendChild($Endereco);
385
                    }
386
                    $this->dom->addChild(
387
                        $EnderecoEstrutura,
388
                        "CEP",
389
                        $ee->cep,
390
                        true
391
                    );
392
                    $this->dom->addChild(
393
                        $EnderecoEstrutura,
394
                        "Municipio",
395
                        $ee->municipio,
396
                        true
397
                    );
398
                    $this->dom->addChild(
399
                        $EnderecoEstrutura,
400
                        "UF",
401
                        $ee->uf,
402
                        true
403
                    );
404
                    $EnderecoOutros->appendChild($EnderecoEstrutura);
405
                }
406
                $this->dom->addChild(
407
                    $EnderecoOutros,
408
                    "Pais",
409
                    $eo->pais,
410
                    true
411
                );
412
413
                $ideDeclarado->appendChild($EnderecoOutros);
414
            }
415
        }
416 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...
417
            foreach ($this->std->paisresid as $pr) {
418
                $paisResid = $this->dom->createElement("paisResid");
419
                $this->dom->addChild(
420
                    $paisResid,
421
                    "Pais",
422
                    $pr->pais,
423
                    true
424
                );
425
                $ideDeclarado->appendChild($paisResid);
426
            }
427
        }
428 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...
429
            foreach ($this->std->paisnacionalidade as $pr) {
430
                $PaisNacionalidade = $this->dom->createElement("PaisNacionalidade");
431
                $this->dom->addChild(
432
                    $PaisNacionalidade,
433
                    "Pais",
434
                    $pr->pais,
435
                    true
436
                );
437
                $ideDeclarado->appendChild($PaisNacionalidade);
438
            }
439
        }
440
        if (!empty($this->std->proprietarios)) {
441
            foreach ($this->std->proprietarios as $p) {
442
                $Proprietarios = $this->dom->createElement("Proprietarios");
443
                $this->dom->addChild(
444
                    $Proprietarios,
445
                    "tpNI",
446
                    $p->tpni,
447
                    true
448
                );
449
                $this->dom->addChild(
450
                    $Proprietarios,
451
                    "NIProprietario",
452
                    $p->niproprietario,
453
                    true
454
                );
455
                $this->dom->addChild(
456
                    $Proprietarios,
457
                    "tpProprietario",
458
                    !empty($p->tpproprietario) ? $p->tpproprietario : null,
459
                    false
460
                );
461
                if (!empty($p->nif)) {
462
                    foreach ($p->nif as $n) {
463
                        $NIF = $this->dom->createElement("NIF");
464
                        $this->dom->addChild(
465
                            $NIF,
466
                            "NumeroNIF",
467
                            $n->numeronif,
468
                            true
469
                        );
470
                        $this->dom->addChild(
471
                            $NIF,
472
                            "PaisEmissaoNIF",
473
                            $n->paisemissaonif,
474
                            true
475
                        );
476
                        $Proprietarios->appendChild($NIF);
477
                    }
478
                }
479
                $this->dom->addChild(
480
                    $Proprietarios,
481
                    "Nome",
482
                    $p->nome,
483
                    true
484
                );
485
                $this->dom->addChild(
486
                    $Proprietarios,
487
                    "tpNome",
488
                    !empty($p->tpnome) ? $p->tpnome : null,
489
                    false
490
                );
491
                
492 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...
493
                    foreach ($p->nomeoutros as $no) {
494
                        $NomeOutros = $this->dom->createElement("NomeOutros");
495
                        $npf = $no->nomepf;
496
                        $NomePF = $this->dom->createElement("NomePF");
497
                        $this->dom->addChild(
498
                            $NomePF,
499
                            "tpNome",
500
                            !empty($npf->tpnome) ? $npf->tpnome : null,
501
                            false
502
                        );
503
                        $this->dom->addChild(
504
                            $NomePF,
505
                            "PrecTitulo",
506
                            !empty($npf->prectitulo) ? $npf->prectitulo : null,
507
                            false
508
                        );
509
                        $this->dom->addChild(
510
                            $NomePF,
511
                            "Titulo",
512
                            !empty($npf->titulo) ? $npf->titulo : null,
513
                            false
514
                        );
515
                        $PrimeiroNome = $this->dom->createElement("PrimeiroNome");
516
                            $pn = $npf->primeironome;
517
                            $this->dom->addChild(
518
                                $PrimeiroNome,
519
                                "Tipo",
520
                                !empty($pn->tipo) ? $pn->tipo : null,
521
                                false
522
                            );
523
                            $this->dom->addChild(
524
                                $PrimeiroNome,
525
                                "Nome",
526
                                $pn->nome,
527
                                true
528
                            );
529
                            $NomePF->appendChild($PrimeiroNome);
530
                        if (!empty($npf->meionome)) {
531
                            foreach ($npf->meionome as $pn) {
532
                                $MeioNome = $this->dom->createElement("MeioNome");
533
                                $this->dom->addChild(
534
                                    $MeioNome,
535
                                    "Tipo",
536
                                    !empty($pn->tipo) ? $pn->tipo : null,
537
                                    false
538
                                );
539
                                $this->dom->addChild(
540
                                    $MeioNome,
541
                                    "Nome",
542
                                    $pn->nome,
543
                                    true
544
                                );
545
                                $NomePF->appendChild($MeioNome);
546
                            }
547
                        }
548
                        if (!empty($npf->prefixonome)) {
549
                            $pn = $npf->prefixonome;
550
                            $PrefixoNome = $this->dom->createElement("PrefixoNome");
551
                            $this->dom->addChild(
552
                                $PrefixoNome,
553
                                "Tipo",
554
                                !empty($pn->tipo) ? $pn->tipo : null,
555
                                false
556
                            );
557
                            $this->dom->addChild(
558
                                $PrefixoNome,
559
                                "Nome",
560
                                $pn->nome,
561
                                true
562
                            );
563
                            $NomePF->appendChild($PrefixoNome);
564
                        }
565
                        $UltimoNome = $this->dom->createElement("UltimoNome");
566
                        $pn = $npf->ultimonome;
567
                        $this->dom->addChild(
568
                            $UltimoNome,
569
                            "Tipo",
570
                            !empty($pn->tipo) ? $pn->tipo : null,
571
                            false
572
                        );
573
                        $this->dom->addChild(
574
                            $UltimoNome,
575
                            "Nome",
576
                            $pn->nome,
577
                            true
578
                        );
579
                        $NomePF->appendChild($UltimoNome);
580
                        $NomeOutros->appendChild($NomePF);
581
                        $Proprietarios->appendChild($NomeOutros);
582
                    }
583
                }
584
                $this->dom->addChild(
585
                    $Proprietarios,
586
                    "EnderecoLivre",
587
                    $p->enderecolivre,
588
                    true
589
                );
590
                $this->dom->addChild(
591
                    $Proprietarios,
592
                    "tpEndereco",
593
                    !empty($p->tpendereco) ? $p->tpendereco : null,
594
                    false
595
                );
596
                $PaisEndereco = $this->dom->createElement("PaisEndereco");
597
                $this->dom->addChild(
598
                    $PaisEndereco,
599
                    "Pais",
600
                    $p->pais,
601
                    true
602
                );
603
                $Proprietarios->appendChild($PaisEndereco);
604
                
605 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...
606
                    foreach ($p->enderecooutros as $eo) {
607
                        $EnderecoOutros = $this->dom->createElement("EnderecoOutros");
608
                        $this->dom->addChild(
609
                            $EnderecoOutros,
610
                            "tpEndereco",
611
                            !empty($eo->tpendereco) ? $eo->tpendereco : null,
612
                            false
613
                        );
614
                        $this->dom->addChild(
615
                            $EnderecoOutros,
616
                            "EnderecoLivre",
617
                            !empty($eo->enderecolivre) ? $eo->enderecolivre : null,
618
                            false
619
                        );
620
                        if (!empty($eo->enderecoestrutura) && empty($eo->enderecolivre)) {
621
                            $ee = $eo->enderecoestrutura;
622
                            $EnderecoEstrutura = $this->dom->createElement("EnderecoEstrutura");
623
                            $this->dom->addChild(
624
                                $EnderecoEstrutura,
625
                                "EnderecoLivre",
626
                                !empty($ee->enderecolivre) ? $ee->enderecolivre : null,
627
                                false
628
                            );
629
                            if (!empty($ee->endereco)) {
630
                                $end = $ee->endereco;
631
                                $Endereco = $this->dom->createElement("Endereco");
632
                                $this->dom->addChild(
633
                                    $Endereco,
634
                                    "Logradouro",
635
                                    !empty($end->logradouro) ? $end->logradouro : null,
636
                                    false
637
                                );
638
                                $this->dom->addChild(
639
                                    $Endereco,
640
                                    "Numero",
641
                                    !empty($end->numero) ? $end->numero : null,
642
                                    false
643
                                );
644
                                $this->dom->addChild(
645
                                    $Endereco,
646
                                    "Complemento",
647
                                    !empty($end->complemento) ? $end->complemento : null,
648
                                    false
649
                                );
650
                                $this->dom->addChild(
651
                                    $Endereco,
652
                                    "Andar",
653
                                    !empty($end->andar) ? $end->andar : null,
654
                                    false
655
                                );
656
                                $this->dom->addChild(
657
                                    $Endereco,
658
                                    "Bairro",
659
                                    !empty($end->bairro) ? $end->bairro : null,
660
                                    false
661
                                );
662
                                $this->dom->addChild(
663
                                    $Endereco,
664
                                    "CaixaPostal",
665
                                    !empty($end->caixapostal) ? $end->caixapostal : null,
666
                                    false
667
                                );
668
                                $EnderecoEstrutura->appendChild($Endereco);
669
                            }
670
                            $this->dom->addChild(
671
                                $EnderecoEstrutura,
672
                                "CEP",
673
                                $ee->cep,
674
                                true
675
                            );
676
                            $this->dom->addChild(
677
                                $EnderecoEstrutura,
678
                                "Municipio",
679
                                $ee->municipio,
680
                                true
681
                            );
682
                            $this->dom->addChild(
683
                                $EnderecoEstrutura,
684
                                "UF",
685
                                $ee->uf,
686
                                true
687
                            );
688
                            $EnderecoOutros->appendChild($EnderecoEstrutura);
689
                        }
690
                        $this->dom->addChild(
691
                            $EnderecoOutros,
692
                            "Pais",
693
                            $eo->pais,
694
                            true
695
                        );
696
                        $Proprietarios->appendChild($EnderecoOutros);
697
                    }
698
                }
699
                
700 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...
701
                    foreach ($p->paisresid as $pr) {
702
                        $paisResid = $this->dom->createElement("paisResid");
703
                        $this->dom->addChild(
704
                            $paisResid,
705
                            "Pais",
706
                            $pr->pais,
707
                            true
708
                        );
709
                        $Proprietarios->appendChild($paisResid);
710
                    }
711
                }
712 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...
713
                    foreach ($p->paisnacionalidade as $pr) {
714
                        $PaisNacionalidade = $this->dom->createElement("PaisNacionalidade");
715
                        $this->dom->addChild(
716
                            $PaisNacionalidade,
717
                            "Pais",
718
                            $pr->pais,
719
                            true
720
                        );
721
                        $Proprietarios->appendChild($PaisNacionalidade);
722
                    }
723
                }
724
                
725
                $this->dom->addChild(
726
                    $Proprietarios,
727
                    "DataNasc",
728
                    !empty($p->datanasc) ? $p->datanasc : null,
729
                    false
730
                );
731
                
732 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...
733
                    $in = $p->infonascimento;
734
                    $InfoNascimento = $this->dom->createElement("InfoNascimento");
735
                    $this->dom->addChild(
736
                        $InfoNascimento,
737
                        "Municipio",
738
                        !empty($in->municipio) ? $in->municipio : null,
739
                        false
740
                    );
741
                    $this->dom->addChild(
742
                        $InfoNascimento,
743
                        "Bairro",
744
                        !empty($in->bairro) ? $in->bairro : null,
745
                        false
746
                    );
747
                    if (!empty($in->pais)) {
748
                        $PaisNasc = $this->dom->createElement("PaisNasc");
749
                        $this->dom->addChild(
750
                            $PaisNasc,
751
                            "Pais",
752
                            $in->pais,
753
                            false
754
                        );
755
                        $InfoNascimento->appendChild($PaisNasc);
756
                    } elseif (!empty($in->antigonomepais)) {
757
                        $PaisNasc = $this->dom->createElement("PaisNasc");
758
                        $this->dom->addChild(
759
                            $PaisNasc,
760
                            "AntigoNomePais",
761
                            $in->antigonomepais,
762
                            false
763
                        );
764
                        $InfoNascimento->appendChild($PaisNasc);
765
                    }
766
                    $Proprietarios->appendChild($InfoNascimento);
767
                }
768
                
769
                
770 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...
771
                    $Reportavel = $this->dom->createElement("Reportavel");
772
                    $this->dom->addChild(
773
                        $Reportavel,
774
                        "Pais",
775
                        $r->pais,
776
                        true
777
                    );
778
                    $Proprietarios->appendChild($Reportavel);
779
                }
780
                $ideDeclarado->appendChild($Proprietarios);
781
            }
782
        }
783
        $this->node->appendChild($ideDeclarado);
784
        
785
        $caixa = $this->dom->createElement("Caixa");
786
        $this->dom->addChild(
787
            $caixa,
788
            "anoCaixa",
789
            $this->std->anocaixa,
790
            true
791
        );
792
        $this->dom->addChild(
793
            $caixa,
794
            "semestre",
795
            $this->std->semestre,
796
            true
797
        );
798
        
799
        $movOpFin = $this->dom->createElement("movOpFinAnual");
800
        
801
        
802
803
        
804
        if (!empty($this->std->conta)) {
805
            foreach ($this->std->conta as $c) {
806
                $Conta = $this->dom->createElement("Conta");
807 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...
808
                    foreach ($c->medjudic as $j) {
809
                        $MedJudic = $this->dom->createElement("MedJudic");
810
                        $this->dom->addChild(
811
                            $MedJudic,
812
                            "NumProcJud",
813
                            $j->numprocjud,
814
                            true
815
                        );
816
                        $this->dom->addChild(
817
                            $MedJudic,
818
                            "Vara",
819
                            $j->vara,
820
                            true
821
                        );
822
                        $this->dom->addChild(
823
                            $MedJudic,
824
                            "SecJud",
825
                            $j->secjud,
826
                            true
827
                        );
828
                        $this->dom->addChild(
829
                            $MedJudic,
830
                            "SubSecJud",
831
                            $j->subsecjud,
832
                            true
833
                        );
834
                        $this->dom->addChild(
835
                            $MedJudic,
836
                            "dtConcessao",
837
                            $j->dtconcessao,
838
                            true
839
                        );
840
                        $this->dom->addChild(
841
                            $MedJudic,
842
                            "dtCassacao",
843
                            !empty($j->dtcassacao) ? $j->dtcassacao : null,
844
                            false
845
                        );
846
                        $Conta->appendChild($MedJudic);
847
                    }
848
                }
849
                
850
                if (!empty($c->infoconta)) {
851
                    $ic = $c->infoconta;
852
                    $infoConta = $this->dom->createElement("infoConta");
853 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...
854
                        $Reportavel = $this->dom->createElement("Reportavel");
855
                        $this->dom->addChild(
856
                            $Reportavel,
857
                            "Pais",
858
                            $r->pais,
859
                            true
860
                        );
861
                        $infoConta->appendChild($Reportavel);
862
                    }
863
                    $this->dom->addChild(
864
                        $infoConta,
865
                        "tpConta",
866
                        $ic->tpconta,
867
                        true
868
                    );
869
                    $this->dom->addChild(
870
                        $infoConta,
871
                        "subTpConta",
872
                        $ic->subtpconta,
873
                        true
874
                    );
875
                    $this->dom->addChild(
876
                        $infoConta,
877
                        "tpNumConta",
878
                        $ic->tpnumconta,
879
                        true
880
                    );
881
                    $this->dom->addChild(
882
                        $infoConta,
883
                        "numConta",
884
                        $ic->numconta,
885
                        true
886
                    );
887
                    $this->dom->addChild(
888
                        $infoConta,
889
                        "tpRelacaoDeclarado",
890
                        $ic->tprelacaodeclarado,
891
                        true
892
                    );
893
894 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...
895
                        $i = $ic->intermediario;
896
                        $Intermediario = $this->dom->createElement("Intermediario");
897
                        $this->dom->addChild(
898
                            $Intermediario,
899
                            "GIIN",
900
                            !empty($i->giin) ? $i->giin : null,
901
                            false
902
                        );
903
                        $this->dom->addChild(
904
                            $Intermediario,
905
                            "tpNI",
906
                            !empty($i->tpni) ? $i->tpni : null,
907
                            false
908
                        );
909
                        $this->dom->addChild(
910
                            $Intermediario,
911
                            "NIIntermediario",
912
                            !empty($i->niintermediario) ? $i->niintermediario : null,
913
                            false
914
                        );
915
                        $infoConta->appendChild($Intermediario);
916
                    }
917
                    $this->dom->addChild(
918
                        $infoConta,
919
                        "NoTitulares",
920
                        !empty($ic->notitulares) ? $ic->notitulares : null,
921
                        false
922
                    );
923
                    $this->dom->addChild(
924
                        $infoConta,
925
                        "dtEncerramentoConta",
926
                        !empty($ic->dtencerramentoconta) ? $ic->dtencerramentoconta : null,
927
                        false
928
                    );
929
                    $this->dom->addChild(
930
                        $infoConta,
931
                        "IndInatividade",
932
                        !empty($ic->indinatividade) ? $ic->indinatividade : null,
933
                        false
934
                    );
935
                    $this->dom->addChild(
936
                        $infoConta,
937
                        "IndNDoc",
938
                        !empty($ic->indndoc) ? $ic->indndoc : null,
939
                        false
940
                    );
941 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...
942
                        $f = $ic->fundo;
943
                        $Fundo = $this->dom->createElement("Fundo");
944
                        $this->dom->addChild(
945
                            $Fundo,
946
                            "GIIN",
947
                            !empty($f->giin) ? $f->giin : null,
948
                            false
949
                        );
950
                        $this->dom->addChild(
951
                            $Fundo,
952
                            "CNPJ",
953
                            $f->cnpj,
954
                            true
955
                        );
956
                        $infoConta->appendChild($Fundo);
957
                    }
958
                    
959
                    $BalancoConta = $this->dom->createElement("BalancoConta");
960
                    $this->dom->addChild(
961
                        $BalancoConta,
962
                        "vlrUltDia",
963
                        !empty($ic->vlrultdia) ? number_format($ic->vlrultdia, 2, ',', '') : null,
964
                        false
965
                    );
966
                    $infoConta->appendChild($BalancoConta);
967
                    
968 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...
969
                        $PgtosAcum = $this->dom->createElement("PgtosAcum");
970
                        $this->dom->addChild(
971
                            $PgtosAcum,
972
                            "tpPgto",
973
                            $pg->tppgto,
974
                            true
975
                        );
976
                        $this->dom->addChild(
977
                            $PgtosAcum,
978
                            "totPgtosAcum",
979
                            number_format($pg->totpgtosacum, 2, ',', ''),
980
                            true
981
                        );
982
                        $infoConta->appendChild($PgtosAcum);
983
                    }
984
                    $Conta->appendChild($infoConta);
985
                }
986
                $movOpFin->appendChild($Conta);
987
            }
988
        }
989
        
990
        $caixa->appendChild($movOpFin);
991
        $this->node->appendChild($caixa);
992
                
993
        //finalização do xml
994
        $this->eFinanceira->appendChild($this->node);
995
        //$this->xml = $this->dom->saveXML($this->eFinanceira);
996
        $this->sign($this->evtTag);
997
    }
998
}
999