Test Failed
Push — master ( 88ea0f...5ac8de )
by Roberto
03:16 queued 14s
created

TraitS1210::toNode250()   F

Complexity

Conditions 53
Paths 162

Size

Total Lines 575

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 575
rs 2.92
c 0
b 0
f 0
cc 53
nc 162
nop 0

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\Traits;
4
5
trait TraitS1210
6
{
7
    /**
8
     * builder for version 2.5.0
9
     */
10
    protected function toNode250()
11
    {
12
        $ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0);
0 ignored issues
show
Bug introduced by
The property node does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
13
        //o idEvento pode variar de evento para evento
14
        //então cada factory individualmente terá de construir o seu
15
        $ideEvento = $this->dom->createElement("ideEvento");
0 ignored issues
show
Bug introduced by
The property dom does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
16
        $this->dom->addChild(
17
            $ideEvento,
18
            "indRetif",
19
            $this->std->indretif,
0 ignored issues
show
Bug introduced by
The property std does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20
            true
21
        );
22
        $this->dom->addChild(
23
            $ideEvento,
24
            "nrRecibo",
25
            !empty($this->std->nrrecibo) ? $this->std->nrrecibo : null,
26
            false
27
        );
28
        $this->dom->addChild(
29
            $ideEvento,
30
            "indApuracao",
31
            $this->std->indapuracao,
32
            true
33
        );
34
        $this->dom->addChild(
35
            $ideEvento,
36
            "perApur",
37
            $this->std->perapur,
38
            true
39
        );
40
        $this->dom->addChild(
41
            $ideEvento,
42
            "tpAmb",
43
            $this->tpAmb,
0 ignored issues
show
Bug introduced by
The property tpAmb does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
44
            true
45
        );
46
        $this->dom->addChild(
47
            $ideEvento,
48
            "procEmi",
49
            $this->procEmi,
0 ignored issues
show
Bug introduced by
The property procEmi does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
50
            true
51
        );
52
        $this->dom->addChild(
53
            $ideEvento,
54
            "verProc",
55
            $this->verProc,
0 ignored issues
show
Bug introduced by
The property verProc does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
56
            true
57
        );
58
        $this->node->insertBefore($ideEvento, $ideEmpregador);
59
        $ideBenef = $this->dom->createElement("ideBenef");
60
        $this->dom->addChild(
61
            $ideBenef,
62
            "cpfBenef",
63
            $this->std->cpfbenef,
64
            true
65
        );
66
        if (!empty($this->std->deps->vrdeddep)) {
67
            $deps = $this->dom->createElement("deps");
68
            $this->dom->addChild(
69
                $deps,
70
                "vrDedDep",
71
                $this->std->deps->vrdeddep,
72
                true
73
            );
74
            $ideBenef->appendChild($deps);
75
        }
76
        foreach ($this->std->infopgto as $pgto) {
77
            $infoPgto = $this->dom->createElement("infoPgto");
78
            $this->dom->addChild(
79
                $infoPgto,
80
                "dtPgto",
81
                $pgto->dtpgto,
82
                true
83
            );
84
            $this->dom->addChild(
85
                $infoPgto,
86
                "tpPgto",
87
                $pgto->tppgto,
88
                true
89
            );
90
            $this->dom->addChild(
91
                $infoPgto,
92
                "indResBr",
93
                $pgto->indresbr,
94
                true
95
            );
96
            if (!empty($pgto->detpgtofl)) {
97
                foreach ($pgto->detpgtofl as $pgtofl) {
98
                    $detPgtoFl = $this->dom->createElement("detPgtoFl");
99
                    $this->dom->addChild(
100
                        $detPgtoFl,
101
                        "perRef",
102
                        !empty($pgtofl->perref) ? $pgtofl->perref : null,
103
                        false
104
                    );
105
                    $this->dom->addChild(
106
                        $detPgtoFl,
107
                        "ideDmDev",
108
                        $pgtofl->idedmdev,
109
                        true
110
                    );
111
                    $this->dom->addChild(
112
                        $detPgtoFl,
113
                        "indPgtoTt",
114
                        $pgtofl->indpgtott,
115
                        true
116
                    );
117
                    $this->dom->addChild(
118
                        $detPgtoFl,
119
                        "vrLiq",
120
                        $pgtofl->vrliq,
121
                        true
122
                    );
123
                    $this->dom->addChild(
124
                        $detPgtoFl,
125
                        "nrRecArq",
126
                        !empty($pgtofl->nrrecarq) ? $pgtofl->nrrecarq : null,
127
                        false
128
                    );
129
                    if (!empty($pgtofl->retpgtotot)) {
130
                        foreach ($pgtofl->retpgtotot as $pg) {
131
                            $retPgtoTot = $this->dom->createElement("retPgtoTot");
132
                            $this->dom->addChild(
133
                                $retPgtoTot,
134
                                "codRubr",
135
                                $pg->codrubr,
136
                                true
137
                            );
138
                            $this->dom->addChild(
139
                                $retPgtoTot,
140
                                "ideTabRubr",
141
                                $pg->idetabrubr,
142
                                true
143
                            );
144
                            $this->dom->addChild(
145
                                $retPgtoTot,
146
                                "qtdRubr",
147
                                !empty($pg->qtdrubr) ? $pg->qtdrubr : null,
148
                                false
149
                            );
150
                            $this->dom->addChild(
151
                                $retPgtoTot,
152
                                "fatorRubr",
153
                                !empty($pg->fatorrubr) ? $pg->fatorrubr : null,
154
                                false
155
                            );
156
                            $this->dom->addChild(
157
                                $retPgtoTot,
158
                                "vrUnit",
159
                                !empty($pg->vrunit) ? $pg->vrunit : null,
160
                                false
161
                            );
162
                            $this->dom->addChild(
163
                                $retPgtoTot,
164
                                "vrRubr",
165
                                $pg->vrrubr,
166
                                true
167
                            );
168
                            if (!empty($pg->penalim)) {
169
                                foreach ($pg->penalim as $pa) {
170
                                    $penAlim = $this->dom->createElement("penAlim");
171
                                    $this->dom->addChild(
172
                                        $penAlim,
173
                                        "cpfBenef",
174
                                        $pa->cpfbenef,
175
                                        true
176
                                    );
177
                                    $this->dom->addChild(
178
                                        $penAlim,
179
                                        "dtNasctoBenef",
180
                                        !empty($pa->dtnasctobenef) ? $pa->dtnasctobenef : null,
181
                                        false
182
                                    );
183
                                    $this->dom->addChild(
184
                                        $penAlim,
185
                                        "nmBenefic",
186
                                        $pa->nmbenefic,
187
                                        true
188
                                    );
189
                                    $this->dom->addChild(
190
                                        $penAlim,
191
                                        "vlrPensao",
192
                                        $pa->vlrpensao,
193
                                        true
194
                                    );
195
                                    $retPgtoTot->appendChild($penAlim);
196
                                    $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...
197
                                }
198
                            }
199
                            $detPgtoFl->appendChild($retPgtoTot);
200
                            $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...
201
                        }
202
                    }
203
                    if (!empty($pgtofl->infopgtoparc)) {
204
                        foreach ($pgtofl->infopgtoparc as $pp) {
205
                            $infoPgtoParc = $this->dom->createElement("infoPgtoParc");
206
                            $this->dom->addChild(
207
                                $infoPgtoParc,
208
                                "matricula",
209
                                !empty($pp->matricula) ? $pp->matricula : null,
210
                                false
211
                            );
212
213
                            $this->dom->addChild(
214
                                $infoPgtoParc,
215
                                "codRubr",
216
                                $pp->codrubr,
217
                                true
218
                            );
219
                            $this->dom->addChild(
220
                                $infoPgtoParc,
221
                                "ideTabRubr",
222
                                $pp->idetabrubr,
223
                                true
224
                            );
225
                            $this->dom->addChild(
226
                                $infoPgtoParc,
227
                                "qtdRubr",
228
                                !empty($pp->qtdrubr) ? $pp->qtdrubr : null,
229
                                false
230
                            );
231
                            $this->dom->addChild(
232
                                $infoPgtoParc,
233
                                "fatorRubr",
234
                                !empty($pp->fatorrubr) ? $pp->fatorrubr : null,
235
                                false
236
                            );
237
                            $this->dom->addChild(
238
                                $infoPgtoParc,
239
                                "vrUnit",
240
                                !empty($pp->vrunit) ? $pp->vrunit : null,
241
                                false
242
                            );
243
                            $this->dom->addChild(
244
                                $infoPgtoParc,
245
                                "vrRubr",
246
                                $pp->vrrubr,
247
                                true
248
                            );
249
                            $detPgtoFl->appendChild($infoPgtoParc);
250
                            $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...
251
                        }
252
                    }
253
                    $infoPgto->appendChild($detPgtoFl);
254
                    $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...
255
                }
256
            }
257
            if (!empty($pgto->detpgtobenpr)) {
258
                $detPgtoBenPr = $this->dom->createElement("detPgtoBenPr");
259
                $this->dom->addChild(
260
                    $detPgtoBenPr,
261
                    "perRef",
262
                    $pgto->detpgtobenpr->perref,
263
                    true
264
                );
265
                $this->dom->addChild(
266
                    $detPgtoBenPr,
267
                    "ideDmDev",
268
                    $pgto->detpgtobenpr->idedmdev,
269
                    true
270
                );
271
                $this->dom->addChild(
272
                    $detPgtoBenPr,
273
                    "indPgtoTt",
274
                    $pgto->detpgtobenpr->indpgtott,
275
                    true
276
                );
277
                $this->dom->addChild(
278
                    $detPgtoBenPr,
279
                    "vrLiq",
280
                    $pgto->detpgtobenpr->vrliq,
281
                    true
282
                );
283
                if (!empty($pgto->detpgtobenpr->retpgtotot)) {
284
                    foreach ($pgto->detpgtobenpr->retpgtotot as $rpt) {
285
                        $retPgtoTot = $this->dom->createElement("retPgtoTot");
286
                        $this->dom->addChild(
287
                            $retPgtoTot,
288
                            "codRubr",
289
                            $rpt->codrubr,
290
                            true
291
                        );
292
                        $this->dom->addChild(
293
                            $retPgtoTot,
294
                            "ideTabRubr",
295
                            $rpt->idetabrubr,
296
                            true
297
                        );
298
                        $this->dom->addChild(
299
                            $retPgtoTot,
300
                            "qtdRubr",
301
                            !empty($rpt->qtdrubr) ? $rpt->qtdrubr : null,
302
                            false
303
                        );
304
                        $this->dom->addChild(
305
                            $retPgtoTot,
306
                            "fatorRubr",
307
                            !empty($rpt->fatorrubr) ? $rpt->fatorrubr : null,
308
                            false
309
                        );
310
                        $this->dom->addChild(
311
                            $retPgtoTot,
312
                            "vrUnit",
313
                            !empty($rpt->vrunit) ? $rpt->vrunit : null,
314
                            false
315
                        );
316
                        $this->dom->addChild(
317
                            $retPgtoTot,
318
                            "vrRubr",
319
                            $rpt->vrrubr,
320
                            true
321
                        );
322
                        $detPgtoBenPr->appendChild($retPgtoTot);
323
                        $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...
324
                    }
325
                }
326
                if (!empty($pgto->detpgtobenpr->infopgtoparc)) {
327
                    foreach ($pgto->detpgtobenpr->infopgtoparc as $rpt) {
328
                        $infoPgtoParc = $this->dom->createElement("infoPgtoParc");
329
                        $this->dom->addChild(
330
                            $infoPgtoParc,
331
                            "codRubr",
332
                            $rpt->codrubr,
333
                            true
334
                        );
335
                        $this->dom->addChild(
336
                            $infoPgtoParc,
337
                            "ideTabRubr",
338
                            $rpt->idetabrubr,
339
                            true
340
                        );
341
                        $this->dom->addChild(
342
                            $infoPgtoParc,
343
                            "qtdRubr",
344
                            !empty($rpt->qtdrubr) ? $rpt->qtdrubr : null,
345
                            false
346
                        );
347
                        $this->dom->addChild(
348
                            $infoPgtoParc,
349
                            "fatorRubr",
350
                            !empty($rpt->fatorrubr) ? $rpt->fatorrubr : null,
351
                            false
352
                        );
353
                        $this->dom->addChild(
354
                            $infoPgtoParc,
355
                            "vrUnit",
356
                            !empty($rpt->vrunit) ? $rpt->vrunit : null,
357
                            false
358
                        );
359
                        $this->dom->addChild(
360
                            $infoPgtoParc,
361
                            "vrRubr",
362
                            $rpt->vrrubr,
363
                            true
364
                        );
365
                        $detPgtoBenPr->appendChild($infoPgtoParc);
366
                        $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...
367
                    }
368
                }
369
                $infoPgto->appendChild($detPgtoBenPr);
370
                $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...
371
            }
372
            if (!empty($pgto->detpgtofer)) {
373
                foreach ($pgto->detpgtofer as $rpt) {
374
                    $detPgtoFer = $this->dom->createElement("detPgtoFer");
375
                    $this->dom->addChild(
376
                        $detPgtoFer,
377
                        "codCateg",
378
                        $rpt->codcateg,
379
                        true
380
                    );
381
                    $this->dom->addChild(
382
                        $detPgtoFer,
383
                        "matricula",
384
                        !empty($rpt->matricula) ? $rpt->matricula : null,
385
                        false
386
                    );
387
                    $this->dom->addChild(
388
                        $detPgtoFer,
389
                        "dtIniGoz",
390
                        $rpt->dtinigoz,
391
                        true
392
                    );
393
                    $this->dom->addChild(
394
                        $detPgtoFer,
395
                        "qtDias",
396
                        $rpt->qtdias,
397
                        true
398
                    );
399
                    $this->dom->addChild(
400
                        $detPgtoFer,
401
                        "vrLiq",
402
                        $rpt->vrliq,
403
                        true
404
                    );
405
                    if (!empty($rpt->detrubrfer)) {
406
                        foreach ($rpt->detrubrfer as $dpt) {
407
                            $detRubrFer = $this->dom->createElement("detRubrFer");
408
                            $this->dom->addChild(
409
                                $detRubrFer,
410
                                "codRubr",
411
                                $dpt->codrubr,
412
                                true
413
                            );
414
                            $this->dom->addChild(
415
                                $detRubrFer,
416
                                "ideTabRubr",
417
                                $dpt->idetabrubr,
418
                                true
419
                            );
420
                            $this->dom->addChild(
421
                                $detRubrFer,
422
                                "qtdRubr",
423
                                !empty($dpt->qtdrubr) ? $dpt->qtdrubr : null,
424
                                false
425
                            );
426
                            $this->dom->addChild(
427
                                $detRubrFer,
428
                                "fatorRubr",
429
                                !empty($dpt->fatorrubr) ? $dpt->fatorrubr : null,
430
                                false
431
                            );
432
                            $this->dom->addChild(
433
                                $detRubrFer,
434
                                "vrUnit",
435
                                !empty($dpt->vrunit) ? $dpt->vrunit : null,
436
                                false
437
                            );
438
                            $this->dom->addChild(
439
                                $detRubrFer,
440
                                "vrRubr",
441
                                $dpt->vrrubr,
442
                                true
443
                            );
444
                            if (!empty($dpt->penalim)) {
445
                                foreach ($dpt->penalim as $xf) {
446
                                    $penAlim = $this->dom->createElement("penAlim");
447
                                    $this->dom->addChild(
448
                                        $penAlim,
449
                                        "cpfBenef",
450
                                        $xf->cpfbenef,
451
                                        true
452
                                    );
453
                                    $this->dom->addChild(
454
                                        $penAlim,
455
                                        "dtNasctoBenef",
456
                                        !empty($xf->dtnasctobenef) ? $xf->dtnasctobenef : null,
457
                                        false
458
                                    );
459
                                    $this->dom->addChild(
460
                                        $penAlim,
461
                                        "nmBenefic",
462
                                        $xf->nmbenefic,
463
                                        true
464
                                    );
465
                                    $this->dom->addChild(
466
                                        $penAlim,
467
                                        "vlrPensao",
468
                                        $xf->vlrpensao,
469
                                        true
470
                                    );
471
                                    $detRubrFer->appendChild($penAlim);
472
                                    $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...
473
                                }
474
                            }
475
                            $detPgtoFer->appendChild($detRubrFer);
476
                            $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...
477
                        }
478
                    }
479
                    $infoPgto->appendChild($detPgtoFer);
480
                    $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...
481
                }
482
            }
483
            if (!empty($pgto->detpgtoant)) {
484
                foreach ($pgto->detpgtoant as $pgant) {
485
                    $detPgtoAnt = $this->dom->createElement("detPgtoAnt");
486
                    $this->dom->addChild(
487
                        $detPgtoAnt,
488
                        "codCateg",
489
                        $pgant->codcateg,
490
                        true
491
                    );
492
                    foreach ($pgant->infopgtoant as $ipa) {
493
                        $infoPgtoAnt = $this->dom->createElement("infoPgtoAnt");
494
                        $this->dom->addChild(
495
                            $infoPgtoAnt,
496
                            "tpBcIRRF",
497
                            $ipa->tpbcirrf,
498
                            true
499
                        );
500
                        $this->dom->addChild(
501
                            $infoPgtoAnt,
502
                            "vrBcIRRF",
503
                            $ipa->vrbcirrf,
504
                            true
505
                        );
506
                        $detPgtoAnt->appendChild($infoPgtoAnt);
507
                        $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...
508
                    }
509
                    $infoPgto->appendChild($detPgtoAnt);
510
                    $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...
511
                }
512
            }
513
            if (!empty($pgto->idepgtoext)) {
514
                $idePgtoExt = $this->dom->createElement("idePgtoExt");
515
                $idePais = $this->dom->createElement("idePais");
516
                $this->dom->addChild(
517
                    $idePais,
518
                    "codPais",
519
                    $pgto->idepgtoext->codpais,
520
                    true
521
                );
522
                $this->dom->addChild(
523
                    $idePais,
524
                    "indNIF",
525
                    $pgto->idepgtoext->indnif,
526
                    true
527
                );
528
                $this->dom->addChild(
529
                    $idePais,
530
                    "nifBenef",
531
                    !empty($pgto->idepgtoext->nifbenef) ? $pgto->idepgtoext->nifbenef : null,
532
                    false
533
                );
534
                $endExt = $this->dom->createElement("endExt");
535
                $this->dom->addChild(
536
                    $endExt,
537
                    "dscLograd",
538
                    $pgto->idepgtoext->endext->dsclograd,
539
                    true
540
                );
541
                $this->dom->addChild(
542
                    $endExt,
543
                    "nrLograd",
544
                    !empty($pgto->idepgtoext->endext->nrlograd) ? $pgto->idepgtoext->endext->nrlograd : null,
545
                    false
546
                );
547
                $this->dom->addChild(
548
                    $endExt,
549
                    "complem",
550
                    !empty($pgto->idepgtoext->endext->complem) ? $pgto->idepgtoext->endext->complem : null,
551
                    false
552
                );
553
                $this->dom->addChild(
554
                    $endExt,
555
                    "bairro",
556
                    !empty($pgto->idepgtoext->endext->bairro) ? $pgto->idepgtoext->endext->bairro : null,
557
                    false
558
                );
559
                $this->dom->addChild(
560
                    $endExt,
561
                    "nmCid",
562
                    $pgto->idepgtoext->endext->nmcid,
563
                    true
564
                );
565
                $this->dom->addChild(
566
                    $endExt,
567
                    "codPostal",
568
                    !empty($pgto->idepgtoext->endext->codoostal) ? $pgto->idepgtoext->endext->codoostal : null,
569
                    false
570
                );
571
                $idePgtoExt->appendChild($idePais);
572
                $idePgtoExt->appendChild($endExt);
573
                $infoPgto->appendChild($idePgtoExt);
574
            }
575
            $ideBenef->appendChild($infoPgto);
576
            $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...
577
        }
578
579
        $this->node->appendChild($ideBenef);
580
        //finalização do xml
581
        $this->eSocial->appendChild($this->node);
0 ignored issues
show
Bug introduced by
The property eSocial does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
582
        //$this->xml = $this->dom->saveXML($this->eSocial);
583
        $this->sign();
0 ignored issues
show
Bug introduced by
It seems like sign() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
584
    }
585
    
586
    /**
587
     * builder for version S.1.0.0
588
     */
589
    protected function toNodeS100()
590
    {
591
        throw new \Exception("TODO !!");
592
    }
593
}
594