Completed
Push — master ( 9654f6...5e67fa )
by Roberto
14:40
created

EvtMovOpFin   D

Complexity

Total Complexity 118

Size/Duplication

Total Lines 1058
Duplicated Lines 43.38 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 118
c 0
b 0
f 0
lcom 1
cbo 2
dl 459
loc 1058
rs 4.4239

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
F toNode() 459 1035 117

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