Passed
Pull Request — master (#134)
by Roberto
03:15
created

EvtPgtos::toNode()   D

Complexity

Conditions 51
Paths 162

Size

Total Lines 569
Code Lines 455

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2652

Importance

Changes 0
Metric Value
dl 0
loc 569
ccs 0
cts 557
cp 0
rs 4
c 0
b 0
f 0
cc 51
eloc 455
nc 162
nop 0
crap 2652

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace NFePHP\eSocial\Factories;
4
5
/**
6
 * Class eSocial EvtPgtos Event S-1210 constructor
7
 *
8
 * @category  NFePHP
9
 * @package   NFePHPSocial
10
 * @copyright NFePHP Copyright (c) 2017
11
 * @license   http://www.gnu.org/licenses/lgpl.txt LGPLv3+
12
 * @license   https://opensource.org/licenses/MIT MIT
13
 * @license   http://www.gnu.org/licenses/gpl.txt GPLv3+
14
 * @author    Roberto L. Machado <linux.rlm at gmail dot com>
15
 * @link      http://github.com/nfephp-org/sped-esocial for the canonical source repository
16
 */
17
18
use NFePHP\Common\Certificate;
19
use NFePHP\eSocial\Common\Factory;
20
use NFePHP\eSocial\Common\FactoryId;
21
use NFePHP\eSocial\Common\FactoryInterface;
22
use stdClass;
23
24
class EvtPgtos extends Factory implements FactoryInterface
25
{
26
    /**
27
     * @var int
28
     */
29
    public $sequencial;
30
31
    /**
32
     * @var string
33
     */
34
    protected $evtName = 'evtPgtos';
35
36
    /**
37
     * @var string
38
     */
39
    protected $evtAlias = 'S-1210';
40
41
    /**
42
     * Parameters patterns
43
     *
44
     * @var array
45
     */
46
    protected $parameters = [];
47
48
    /**
49
     * Constructor
50
     *
51
     * @param string $config
52
     * @param stdClass $std
53
     * @param Certificate $certificate
54
     */
55
    public function __construct(
56
        $config,
57
        stdClass $std,
58
        Certificate $certificate
59
    ) {
60
        parent::__construct($config, $std, $certificate);
61
    }
62
63
    /**
64
     * Node constructor
65
     */
66
    protected function toNode()
67
    {
68
        $ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0);
69
        //o idEvento pode variar de evento para evento
70
        //então cada factory individualmente terá de construir o seu
71
        $ideEvento = $this->dom->createElement("ideEvento");
72
        $this->dom->addChild(
73
            $ideEvento,
74
            "indRetif",
75
            $this->std->indretif,
76
            true
77
        );
78
        $this->dom->addChild(
79
            $ideEvento,
80
            "nrRecibo",
81
            ! empty($this->std->nrrecibo) ? $this->std->nrrecibo : null,
82
            false
83
        );
84
        $this->dom->addChild(
85
            $ideEvento,
86
            "indApuracao",
87
            $this->std->indapuracao,
88
            true
89
        );
90
        $this->dom->addChild(
91
            $ideEvento,
92
            "perApur",
93
            $this->std->perapur,
94
            true
95
        );
96
        $this->dom->addChild(
97
            $ideEvento,
98
            "tpAmb",
99
            $this->tpAmb,
100
            true
101
        );
102
        $this->dom->addChild(
103
            $ideEvento,
104
            "procEmi",
105
            $this->procEmi,
106
            true
107
        );
108
        $this->dom->addChild(
109
            $ideEvento,
110
            "verProc",
111
            $this->verProc,
112
            true
113
        );
114
        $this->node->insertBefore($ideEvento, $ideEmpregador);
115
        
116
        $ideBenef = $this->dom->createElement("ideBenef");
117
        $this->dom->addChild(
118
            $ideBenef,
119
            "cpfBenef",
120
            $this->std->idebenef->cpfbenef,
121
            true
122
        );
123
        
124
        if (!empty($this->std->idebenef->vrdeddep)) {
125
            $deps = $this->dom->createElement("deps");
126
            $this->dom->addChild(
127
                $deps,
128
                "vrDedDep",
129
                $this->std->idebenef->vrdeddep,
130
                true
131
            );
132
            $ideBenef->appendChild($deps);
133
        }
134
        
135
        foreach ($this->std->idebenef->infopgto as $pgto) {
136
            $infoPgto = $this->dom->createElement("infoPgto");
137
            $this->dom->addChild(
138
                $infoPgto,
139
                "dtPgto",
140
                $pgto->dtpgto,
141
                true
142
            );
143
            $this->dom->addChild(
144
                $infoPgto,
145
                "tpPgto",
146
                $pgto->tppgto,
147
                true
148
            );
149
            $this->dom->addChild(
150
                $infoPgto,
151
                "indResBr",
152
                $pgto->indresbr,
153
                true
154
            );
155
            
156
            if (!empty($pgto->detpgtofl)) {
157
                foreach ($pgto->detpgtofl as $pgtofl) {
158
                    $detPgtoFl = $this->dom->createElement("detPgtoFl");
159
                    $this->dom->addChild(
160
                        $detPgtoFl,
161
                        "perRef",
162
                        !empty($pgtofl->perref) ? $pgtofl->perref : null,
163
                        false
164
                    );
165
                    $this->dom->addChild(
166
                        $detPgtoFl,
167
                        "ideDmDev",
168
                        $pgtofl->idedmdev,
169
                        true
170
                    );
171
                    $this->dom->addChild(
172
                        $detPgtoFl,
173
                        "indPgtoTt",
174
                        $pgtofl->indpgtott,
175
                        true
176
                    );
177
                    $this->dom->addChild(
178
                        $detPgtoFl,
179
                        "vrLiq",
180
                        $pgtofl->vrliq,
181
                        true
182
                    );
183
                    $this->dom->addChild(
184
                        $detPgtoFl,
185
                        "nrRecArq",
186
                        !empty($pgtofl->nrrecarq) ? $pgtofl->nrrecarq : null,
187
                        false
188
                    );
189
                    if (!empty($pgtofl->retpgtotot)) {
190
                        foreach ($pgtofl->retpgtotot as $pg) {
191
                            $retPgtoTot  = $this->dom->createElement("retPgtoTot");
192
                            $this->dom->addChild(
193
                                $retPgtoTot,
194
                                "codRubr",
195
                                $pg->codrubr,
196
                                true
197
                            );
198
                            $this->dom->addChild(
199
                                $retPgtoTot,
200
                                "ideTabRubr",
201
                                $pg->idetabrubr,
202
                                true
203
                            );
204
                            $this->dom->addChild(
205
                                $retPgtoTot,
206
                                "qtdRubr",
207
                                !empty($pg->qtdrubr) ? $pg->qtdrubr : null,
208
                                false
209
                            );
210
                            $this->dom->addChild(
211
                                $retPgtoTot,
212
                                "fatorRubr",
213
                                !empty($pg->fatorrubr) ? $pg->fatorrubr : null,
214
                                false
215
                            );
216
                            $this->dom->addChild(
217
                                $retPgtoTot,
218
                                "vrUnit",
219
                                !empty($pg->vrunit) ? $pg->vrunit : null,
220
                                false
221
                            );
222
                            $this->dom->addChild(
223
                                $retPgtoTot,
224
                                "vrRubr",
225
                                $pg->vrrubr,
226
                                true
227
                            );
228
                            if (!empty($pg->penalim)) {
229
                                foreach ($pg->penalim as $pa) {
230
                                    $penAlim = $this->dom->createElement("penAlim");
231
                                    $this->dom->addChild(
232
                                        $penAlim,
233
                                        "cpfBenef",
234
                                        $pa->cpfbenef,
235
                                        true
236
                                    );
237
                                        $this->dom->addChild(
238
                                            $penAlim,
239
                                            "dtNasctoBenef",
240
                                            !empty($pa->dtnasctobenef) ? $pa->dtnasctobenef : null,
241
                                            true
242
                                        );
243
                                        $this->dom->addChild(
244
                                            $penAlim,
245
                                            "nmBenefic",
246
                                            $pa->nmbenefic,
247
                                            true
248
                                        );
249
                                        $this->dom->addChild(
250
                                            $penAlim,
251
                                            "vlrPensao",
252
                                            $pa->vlrpensao,
253
                                            true
254
                                        );
255
                                        $retPgtoTot->appendChild($penAlim);
256
                                        $penAlim = null;
0 ignored issues
show
Unused Code introduced by
$penAlim is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
257
                                }
258
                            }
259
                            $detPgtoFl->appendChild($retPgtoTot);
260
                            $retPgtoTot = null;
0 ignored issues
show
Unused Code introduced by
$retPgtoTot is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
261
                        }
262
                    }
263
                    if (!empty($pgtofl->infopgtoparc)) {
264
                        foreach ($pgtofl->infopgtoparc as $pp) {
265
                            $infoPgtoParc = $this->dom->createElement("infoPgtoParc");
266
                            $this->dom->addChild(
267
                                $infoPgtoParc,
268
                                "codRubr",
269
                                $pp->codrubr,
270
                                true
271
                            );
272
                                $this->dom->addChild(
273
                                    $infoPgtoParc,
274
                                    "ideTabRubr",
275
                                    $pp->idetabrubr,
276
                                    true
277
                                );
278
                                $this->dom->addChild(
279
                                    $infoPgtoParc,
280
                                    "qtdRubr",
281
                                    !empty($pp->qtdrubr) ? $pp->qtdrubr : null,
282
                                    false
283
                                );
284
                                $this->dom->addChild(
285
                                    $infoPgtoParc,
286
                                    "fatorRubr",
287
                                    !empty($pp->fatorrubr) ? $pp->fatorrubr : null,
288
                                    false
289
                                );
290
                                $this->dom->addChild(
291
                                    $infoPgtoParc,
292
                                    "vrUnit",
293
                                    !empty($pp->vrunit) ? $pp->vrunit : null,
294
                                    false
295
                                );
296
                                $this->dom->addChild(
297
                                    $infoPgtoParc,
298
                                    "vrRubr",
299
                                    $pp->vrrubr,
300
                                    true
301
                                );
302
                                $detPgtoFl->appendChild($infoPgtoParc);
303
                                $infoPgtoParc = null;
0 ignored issues
show
Unused Code introduced by
$infoPgtoParc is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
304
                        }
305
                    }
306
                    $infoPgto->appendChild($detPgtoFl);
307
                    $detPgtoFl = null;
0 ignored issues
show
Unused Code introduced by
$detPgtoFl is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
308
                }
309
            }
310
            if (!empty($pgto->detpgtobenpr)) {
311
                $detPgtoBenPr = $this->dom->createElement("detPgtoBenPr");
312
                $this->dom->addChild(
313
                    $detPgtoBenPr,
314
                    "perRef",
315
                    $pgto->detpgtobenpr->perref,
316
                    true
317
                );
318
                $this->dom->addChild(
319
                    $detPgtoBenPr,
320
                    "ideDmDev",
321
                    $pgto->detpgtobenpr->idedmdev,
322
                    true
323
                );
324
                $this->dom->addChild(
325
                    $detPgtoBenPr,
326
                    "indPgtoTt",
327
                    $pgto->detpgtobenpr->indpgtott,
328
                    true
329
                );
330
                $this->dom->addChild(
331
                    $detPgtoBenPr,
332
                    "vrLiq",
333
                    $pgto->detpgtobenpr->vrliq,
334
                    true
335
                );
336
                if (!empty($pgto->detpgtobenpr->retpgtotot)) {
337
                    foreach ($pgto->detpgtobenpr->retpgtotot as $rpt) {
338
                        $retPgtoTot = $this->dom->createElement("retPgtoTot");
339
                        $this->dom->addChild(
340
                            $retPgtoTot,
341
                            "codRubr",
342
                            $rpt->codrubr,
343
                            true
344
                        );
345
                            $this->dom->addChild(
346
                                $retPgtoTot,
347
                                "ideTabRubr",
348
                                $rpt->idetabrubr,
349
                                true
350
                            );
351
                            $this->dom->addChild(
352
                                $retPgtoTot,
353
                                "qtdRubr",
354
                                !empty($rpt->qtdrubr) ? $rpt->qtdrubr : null,
355
                                false
356
                            );
357
                            $this->dom->addChild(
358
                                $retPgtoTot,
359
                                "fatorRubr",
360
                                !empty($rpt->fatorrubr) ? $rpt->fatorrubr : null,
361
                                false
362
                            );
363
                            $this->dom->addChild(
364
                                $retPgtoTot,
365
                                "vrUnit",
366
                                !empty($rpt->vrunit) ? $rpt->vrunit : null,
367
                                false
368
                            );
369
                            $this->dom->addChild(
370
                                $retPgtoTot,
371
                                "vrRubr",
372
                                $rpt->vrrubr,
373
                                true
374
                            );
375
                            $detPgtoBenPr->appendChild($retPgtoTot);
376
                            $retPgtoTot = null;
0 ignored issues
show
Unused Code introduced by
$retPgtoTot is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
377
                    }
378
                }
379
                if (!empty($pgto->detpgtobenpr->infopgtoparc)) {
380
                    foreach ($pgto->detpgtobenpr->infopgtoparc as $rpt) {
381
                        $infoPgtoParc = $this->dom->createElement("infoPgtoParc");
382
                        $this->dom->addChild(
383
                            $infoPgtoParc,
384
                            "codRubr",
385
                            $rpt->codrubr,
386
                            true
387
                        );
388
                            $this->dom->addChild(
389
                                $infoPgtoParc,
390
                                "ideTabRubr",
391
                                $rpt->idetabrubr,
392
                                true
393
                            );
394
                            $this->dom->addChild(
395
                                $infoPgtoParc,
396
                                "qtdRubr",
397
                                !empty($rpt->qtdrubr) ? $rpt->qtdrubr : null,
398
                                false
399
                            );
400
                            $this->dom->addChild(
401
                                $infoPgtoParc,
402
                                "fatorRubr",
403
                                !empty($rpt->fatorrubr) ? $rpt->fatorrubr : null,
404
                                false
405
                            );
406
                            $this->dom->addChild(
407
                                $infoPgtoParc,
408
                                "vrUnit",
409
                                !empty($rpt->vrunit) ? $rpt->vrunit : null,
410
                                false
411
                            );
412
                            $this->dom->addChild(
413
                                $infoPgtoParc,
414
                                "vrRubr",
415
                                $rpt->vrrubr,
416
                                true
417
                            );
418
                            $detPgtoBenPr->appendChild($infoPgtoParc);
419
                            $infoPgtoParc = null;
0 ignored issues
show
Unused Code introduced by
$infoPgtoParc is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
420
                    }
421
                }
422
                $infoPgto->appendChild($detPgtoBenPr);
423
                $detPgtoBenPr = null;
0 ignored issues
show
Unused Code introduced by
$detPgtoBenPr is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
424
            }
425
            if (!empty($pgto->detpgtofer)) {
426
                foreach ($pgto->detpgtofer as $rpt) {
427
                    $detPgtoFer = $this->dom->createElement("detPgtoFer");
428
                    $this->dom->addChild(
429
                        $detPgtoFer,
430
                        "codCateg",
431
                        $rpt->codcateg,
432
                        true
433
                    );
434
                        $this->dom->addChild(
435
                            $detPgtoFer,
436
                            "dtIniGoz",
437
                            $rpt->dtinigoz,
438
                            true
439
                        );
440
                        $this->dom->addChild(
441
                            $detPgtoFer,
442
                            "qtDias",
443
                            $rpt->qtdias,
444
                            true
445
                        );
446
                        $this->dom->addChild(
447
                            $detPgtoFer,
448
                            "vrLiq",
449
                            $rpt->vrliq,
450
                            true
451
                        );
452
                    if (!empty($rpt->detrubrfer)) {
453
                        foreach ($rpt->detrubrfer as $dpt) {
454
                            $detRubrFer = $this->dom->createElement("detRubrFer");
455
                            $this->dom->addChild(
456
                                $detRubrFer,
457
                                "codRubr",
458
                                $dpt->codrubr,
459
                                true
460
                            );
461
                                    $this->dom->addChild(
462
                                        $detRubrFer,
463
                                        "ideTabRubr",
464
                                        $dpt->idetabrubr,
465
                                        true
466
                                    );
467
                                    $this->dom->addChild(
468
                                        $detRubrFer,
469
                                        "qtdRubr",
470
                                        !empty($dpt->qtdrubr) ? $dpt->qtdrubr : null,
471
                                        false
472
                                    );
473
                                    $this->dom->addChild(
474
                                        $detRubrFer,
475
                                        "fatorRubr",
476
                                        !empty($dpt->fatorrubr) ? $dpt->fatorrubr : null,
477
                                        false
478
                                    );
479
                                    $this->dom->addChild(
480
                                        $detRubrFer,
481
                                        "vrUnit",
482
                                        !empty($dpt->vrunit) ? $dpt->vrunit : null,
483
                                        false
484
                                    );
485
                                    $this->dom->addChild(
486
                                        $detRubrFer,
487
                                        "vrRubr",
488
                                        $dpt->vrrubr,
489
                                        true
490
                                    );
491
                            if (!empty($dpt->penalim)) {
492
                                foreach ($dpt->penalim as $xf) {
493
                                        $penAlim = $this->dom->createElement("penAlim");
494
                                        $this->dom->addChild(
495
                                            $penAlim,
496
                                            "cpfBenef",
497
                                            $xf->cpfbenef,
498
                                            true
499
                                        );
500
                                        $this->dom->addChild(
501
                                            $penAlim,
502
                                            "dtNasctoBenef",
503
                                            !empty($xf->dtnasctobenef) ? $xf->dtnasctobenef : null,
504
                                            true
505
                                        );
506
                                        $this->dom->addChild(
507
                                            $penAlim,
508
                                            "nmBenefic",
509
                                            $xf->nmbenefic,
510
                                            true
511
                                        );
512
                                        $this->dom->addChild(
513
                                            $penAlim,
514
                                            "vlrPensao",
515
                                            $xf->vlrpensao,
516
                                            true
517
                                        );
518
                                        $detRubrFer->appendChild($penAlim);
519
                                        $penAlim = null;
0 ignored issues
show
Unused Code introduced by
$penAlim is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
520
                                }
521
                            }
522
                                    $detPgtoFer->appendChild($detRubrFer);
523
                                    $detRubrFer = null;
0 ignored issues
show
Unused Code introduced by
$detRubrFer is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
524
                        }
525
                    }
526
                        $infoPgto->appendChild($detPgtoFer);
527
                        $detPgtoFer = null;
0 ignored issues
show
Unused Code introduced by
$detPgtoFer is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
528
                }
529
            }
530
            if (!empty($pgto->detpgtoant)) {
531
                foreach ($pgto->detpgtoant as $pgant) {
532
                    $detPgtoAnt = $this->dom->createElement("detPgtoAnt");
533
                    $this->dom->addChild(
534
                        $detPgtoAnt,
535
                        "codCateg",
536
                        $pgant->codcateg,
537
                        true
538
                    );
539
                    foreach ($pgant->infopgtoant as $ipa) {
540
                       //echo "<pre>";
541
                       //print_r($ipa);
542
                    //echo "</pre>";
543
                    //die;
544
                        $infoPgtoAnt = $this->dom->createElement("infoPgtoAnt");
545
                        $this->dom->addChild(
546
                            $infoPgtoAnt,
547
                            "tpBcIRRF",
548
                            $ipa->tpbcirrf,
549
                            true
550
                        );
551
                        $this->dom->addChild(
552
                            $infoPgtoAnt,
553
                            "vrBcIRRF",
554
                            $ipa->vrbcirrf,
555
                            true
556
                        );
557
                        $detPgtoAnt->appendChild($infoPgtoAnt);
558
                        $infoPgtoAnt = null;
0 ignored issues
show
Unused Code introduced by
$infoPgtoAnt is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
559
                    }
560
                    $infoPgto->appendChild($detPgtoAnt);
561
                    $detPgtoAnt = null;
0 ignored issues
show
Unused Code introduced by
$detPgtoAnt is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
562
                }
563
            }
564
            if (!empty($pgto->idepgtoext)) {
565
                $idePgtoExt = $this->dom->createElement("idePgtoExt");
566
                $idePais = $this->dom->createElement("idePais");
567
                $this->dom->addChild(
568
                    $idePais,
569
                    "codPais",
570
                    $pgto->idepgtoext->codpais,
571
                    true
572
                );
573
                $this->dom->addChild(
574
                    $idePais,
575
                    "indNIF",
576
                    $pgto->idepgtoext->indnif,
577
                    true
578
                );
579
                $this->dom->addChild(
580
                    $idePais,
581
                    "nifBenef",
582
                    !empty($pgto->idepgtoext->nifbenef) ? $pgto->idepgtoext->nifbenef : null,
583
                    false
584
                );
585
                $endExt = $this->dom->createElement("endExt");
586
                $this->dom->addChild(
587
                    $endExt,
588
                    "dscLograd",
589
                    $pgto->idepgtoext->dsclograd,
590
                    true
591
                );
592
                $this->dom->addChild(
593
                    $endExt,
594
                    "nrLograd",
595
                    !empty($pgto->idepgtoext->nrlograd) ? $pgto->idepgtoext->nrlograd : null,
596
                    false
597
                );
598
                $this->dom->addChild(
599
                    $endExt,
600
                    "complem",
601
                    !empty($pgto->idepgtoext->complem) ? $pgto->idepgtoext->complem : null,
602
                    false
603
                );
604
                $this->dom->addChild(
605
                    $endExt,
606
                    "bairro",
607
                    !empty($pgto->idepgtoext->bairro) ? $pgto->idepgtoext->bairro : null,
608
                    false
609
                );
610
                $this->dom->addChild(
611
                    $endExt,
612
                    "nmCid",
613
                    $pgto->idepgtoext->nmcid,
614
                    true
615
                );
616
                $this->dom->addChild(
617
                    $endExt,
618
                    "codPostal",
619
                    !empty($pgto->idepgtoext->codoostal) ? $pgto->idepgtoext->codoostal : null,
620
                    false
621
                );
622
                $idePgtoExt->appendChild($idePais);
623
                $idePgtoExt->appendChild($endExt);
624
                $infoPgto->appendChild($idePgtoExt);
625
            }
626
            $ideBenef->appendChild($infoPgto);
627
            $infoPgto = null;
0 ignored issues
show
Unused Code introduced by
$infoPgto is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
628
        }
629
        $this->node->appendChild($ideBenef);
630
        //finalização do xml
631
        $this->eSocial->appendChild($this->node);
632
        //$this->xml = $this->dom->saveXML($this->eSocial);
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...
633
        $this->sign($this->eSocial);
0 ignored issues
show
Unused Code introduced by
The call to EvtPgtos::sign() has too many arguments starting with $this->eSocial.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
634
    }
635
}
636