Conditions | 52 |
Paths | 576 |
Total Lines | 593 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
10 | protected function toNode250() |
||
11 | { |
||
12 | $ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); |
||
|
|||
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"); |
||
16 | $this->dom->addChild( |
||
17 | $ideEvento, |
||
18 | "indRetif", |
||
19 | $this->std->indretif, |
||
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 | "tpAmb", |
||
31 | $this->tpAmb, |
||
32 | true |
||
33 | ); |
||
34 | $this->dom->addChild( |
||
35 | $ideEvento, |
||
36 | "procEmi", |
||
37 | $this->procEmi, |
||
38 | true |
||
39 | ); |
||
40 | $this->dom->addChild( |
||
41 | $ideEvento, |
||
42 | "verProc", |
||
43 | $this->verProc, |
||
44 | true |
||
45 | ); |
||
46 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
47 | $ideVinculo = $this->dom->createElement("ideVinculo"); |
||
48 | $this->dom->addChild( |
||
49 | $ideVinculo, |
||
50 | "cpfTrab", |
||
51 | $this->std->cpftrab, |
||
52 | true |
||
53 | ); |
||
54 | $this->dom->addChild( |
||
55 | $ideVinculo, |
||
56 | "nisTrab", |
||
57 | $this->std->nistrab, |
||
58 | true |
||
59 | ); |
||
60 | $this->dom->addChild( |
||
61 | $ideVinculo, |
||
62 | "matricula", |
||
63 | $this->std->matricula, |
||
64 | true |
||
65 | ); |
||
66 | $this->node->appendChild($ideVinculo); |
||
67 | $infoDeslig = $this->dom->createElement("infoDeslig"); |
||
68 | $this->dom->addChild( |
||
69 | $infoDeslig, |
||
70 | "mtvDeslig", |
||
71 | $this->std->mtvdeslig, |
||
72 | true |
||
73 | ); |
||
74 | $this->dom->addChild( |
||
75 | $infoDeslig, |
||
76 | "dtDeslig", |
||
77 | $this->std->dtdeslig, |
||
78 | true |
||
79 | ); |
||
80 | $this->dom->addChild( |
||
81 | $infoDeslig, |
||
82 | "indPagtoAPI", |
||
83 | $this->std->indpagtoapi, |
||
84 | true |
||
85 | ); |
||
86 | $this->dom->addChild( |
||
87 | $infoDeslig, |
||
88 | "dtProjFimAPI", |
||
89 | !empty($this->std->dtprojfimapi) ? $this->std->dtprojfimapi : null, |
||
90 | false |
||
91 | ); |
||
92 | $this->dom->addChild( |
||
93 | $infoDeslig, |
||
94 | "pensAlim", |
||
95 | $this->std->pensalim, |
||
96 | true |
||
97 | ); |
||
98 | $this->dom->addChild( |
||
99 | $infoDeslig, |
||
100 | "percAliment", |
||
101 | !empty($this->std->percaliment) ? $this->std->percaliment : null, |
||
102 | false |
||
103 | ); |
||
104 | $this->dom->addChild( |
||
105 | $infoDeslig, |
||
106 | "vrAlim", |
||
107 | !empty($this->std->vralim) ? $this->std->vralim : null, |
||
108 | false |
||
109 | ); |
||
110 | $this->dom->addChild( |
||
111 | $infoDeslig, |
||
112 | "nrCertObito", |
||
113 | !empty($this->std->nrcertobito) ? $this->std->nrcertobito : null, |
||
114 | false |
||
115 | ); |
||
116 | $this->dom->addChild( |
||
117 | $infoDeslig, |
||
118 | "nrProcTrab", |
||
119 | !empty($this->std->nrproctrab) ? $this->std->nrproctrab : null, |
||
120 | false |
||
121 | ); |
||
122 | $this->dom->addChild( |
||
123 | $infoDeslig, |
||
124 | "indCumprParc", |
||
125 | $this->std->indcumprparc, |
||
126 | true |
||
127 | ); |
||
128 | $this->dom->addChild( |
||
129 | $infoDeslig, |
||
130 | "qtdDiasInterm", |
||
131 | !empty($this->std->qtddiasinterm) ? $this->std->qtddiasinterm : null, |
||
132 | false |
||
133 | ); |
||
134 | if (!empty($this->std->observacoes)) { |
||
135 | foreach ($this->std->observacoes as $obs) { |
||
136 | $observacoes = $this->dom->createElement("observacoes"); |
||
137 | $this->dom->addChild( |
||
138 | $observacoes, |
||
139 | "observacao", |
||
140 | $obs->observacao, |
||
141 | false |
||
142 | ); |
||
143 | $infoDeslig->appendChild($observacoes); |
||
144 | } |
||
145 | } |
||
146 | if (!empty($this->std->sucessaovinc)) { |
||
147 | $sucessaoVinc = $this->dom->createElement("sucessaoVinc"); |
||
148 | $this->dom->addChild( |
||
149 | $sucessaoVinc, |
||
150 | "tpInscSuc", |
||
151 | !empty($this->std->sucessaovinc->tpinscsuc) ? $this->std->sucessaovinc->tpinscsuc : null, |
||
152 | false |
||
153 | ); |
||
154 | $this->dom->addChild( |
||
155 | $sucessaoVinc, |
||
156 | "cnpjSucessora", |
||
157 | $this->std->sucessaovinc->cnpjsucessora, |
||
158 | true |
||
159 | ); |
||
160 | $infoDeslig->appendChild($sucessaoVinc); |
||
161 | } |
||
162 | if (!empty($this->std->transftit)) { |
||
163 | $transfTit = $this->dom->createElement("transfTit"); |
||
164 | $this->dom->addChild( |
||
165 | $transfTit, |
||
166 | "cpfSubstituto", |
||
167 | $this->std->transftit->cpfsubstituto, |
||
168 | true |
||
169 | ); |
||
170 | $this->dom->addChild( |
||
171 | $transfTit, |
||
172 | "dtNascto", |
||
173 | $this->std->transftit->dtnascto, |
||
174 | true |
||
175 | ); |
||
176 | $infoDeslig->appendChild($transfTit); |
||
177 | } |
||
178 | if (!empty($this->std->mudancacpf)) { |
||
179 | $mudancaCPF = $this->dom->createElement("mudancaCPF"); |
||
180 | $mcpf = $this->std->mudancacpf; |
||
181 | $this->dom->addChild( |
||
182 | $mudancaCPF, |
||
183 | "novoCPF", |
||
184 | $mcpf->novocpf, |
||
185 | true |
||
186 | ); |
||
187 | $infoDeslig->appendChild($mudancaCPF); |
||
188 | } |
||
189 | |||
190 | if (!empty($this->std->verbasresc)) { |
||
191 | $verbasResc = $this->dom->createElement("verbasResc"); |
||
192 | foreach ($this->std->verbasresc->dmdev as $dm) { |
||
193 | $dmDev = $this->dom->createElement("dmDev"); |
||
194 | $this->dom->addChild( |
||
195 | $dmDev, |
||
196 | "ideDmDev", |
||
197 | $dm->idedmdev, |
||
198 | true |
||
199 | ); |
||
200 | if (!empty($dm->infoperapur)) { |
||
201 | $infoPerApur = $this->dom->createElement("infoPerApur"); |
||
202 | foreach ($dm->infoperapur->ideestablot as $isl) { |
||
203 | $ideEstabLot = $this->dom->createElement("ideEstabLot"); |
||
204 | $this->dom->addChild( |
||
205 | $ideEstabLot, |
||
206 | "tpInsc", |
||
207 | $isl->tpinsc, |
||
208 | true |
||
209 | ); |
||
210 | $this->dom->addChild( |
||
211 | $ideEstabLot, |
||
212 | "nrInsc", |
||
213 | $isl->nrinsc, |
||
214 | true |
||
215 | ); |
||
216 | $this->dom->addChild( |
||
217 | $ideEstabLot, |
||
218 | "codLotacao", |
||
219 | $isl->codlotacao, |
||
220 | true |
||
221 | ); |
||
222 | foreach ($isl->detverbas as $dv) { |
||
223 | $detVerbas = $this->dom->createElement("detVerbas"); |
||
224 | $this->dom->addChild( |
||
225 | $detVerbas, |
||
226 | "codRubr", |
||
227 | $dv->codrubr, |
||
228 | true |
||
229 | ); |
||
230 | $this->dom->addChild( |
||
231 | $detVerbas, |
||
232 | "ideTabRubr", |
||
233 | $dv->idetabrubr, |
||
234 | true |
||
235 | ); |
||
236 | $this->dom->addChild( |
||
237 | $detVerbas, |
||
238 | "qtdRubr", |
||
239 | !empty($dv->qtdrubr) ? $dv->qtdrubr : null, |
||
240 | false |
||
241 | ); |
||
242 | $this->dom->addChild( |
||
243 | $detVerbas, |
||
244 | "fatorRubr", |
||
245 | !empty($dv->fatorrubr) ? $dv->fatorrubr : null, |
||
246 | false |
||
247 | ); |
||
248 | $this->dom->addChild( |
||
249 | $detVerbas, |
||
250 | "vrUnit", |
||
251 | !empty($dv->vrunit) ? $dv->vrunit : null, |
||
252 | false |
||
253 | ); |
||
254 | $this->dom->addChild( |
||
255 | $detVerbas, |
||
256 | "vrRubr", |
||
257 | $dv->vrrubr, |
||
258 | true |
||
259 | ); |
||
260 | $ideEstabLot->appendChild($detVerbas); |
||
261 | } |
||
262 | if (!empty($isl->infosaudecolet)) { |
||
263 | $infoSaudeColet = $this->dom->createElement("infoSaudeColet"); |
||
264 | foreach ($isl->infosaudecolet->detoper as $do) { |
||
265 | $detOper = $this->dom->createElement("detOper"); |
||
266 | $this->dom->addChild( |
||
267 | $detOper, |
||
268 | "cnpjOper", |
||
269 | $do->cnpjoper, |
||
270 | true |
||
271 | ); |
||
272 | $this->dom->addChild( |
||
273 | $detOper, |
||
274 | "regANS", |
||
275 | $do->regans, |
||
276 | true |
||
277 | ); |
||
278 | $this->dom->addChild( |
||
279 | $detOper, |
||
280 | "vrPgTit", |
||
281 | $do->vrpgtit, |
||
282 | true |
||
283 | ); |
||
284 | if (!empty($do->detplano)) { |
||
285 | foreach ($do->detplano as $dp) { |
||
286 | $detPlano = $this->dom->createElement("detPlano"); |
||
287 | $this->dom->addChild( |
||
288 | $detPlano, |
||
289 | "tpDep", |
||
290 | $dp->tpdep, |
||
291 | true |
||
292 | ); |
||
293 | $this->dom->addChild( |
||
294 | $detPlano, |
||
295 | "cpfDep", |
||
296 | !empty($dp->cpfdep) ? $dp->cpfdep : null, |
||
297 | false |
||
298 | ); |
||
299 | $this->dom->addChild( |
||
300 | $detPlano, |
||
301 | "nmDep", |
||
302 | $dp->nmdep, |
||
303 | true |
||
304 | ); |
||
305 | $this->dom->addChild( |
||
306 | $detPlano, |
||
307 | "dtNascto", |
||
308 | $dp->dtnascto, |
||
309 | true |
||
310 | ); |
||
311 | $this->dom->addChild( |
||
312 | $detPlano, |
||
313 | "vlrPgDep", |
||
314 | $dp->vlrpgdep, |
||
315 | true |
||
316 | ); |
||
317 | $detOper->appendChild($detPlano); |
||
318 | } |
||
319 | } |
||
320 | $infoSaudeColet->appendChild($detOper); |
||
321 | } |
||
322 | $ideEstabLot->appendChild($infoSaudeColet); |
||
323 | } |
||
324 | if (!empty($isl->infoagnocivo)) { |
||
325 | $infoAgNocivo = $this->dom->createElement("infoAgNocivo"); |
||
326 | $this->dom->addChild( |
||
327 | $infoAgNocivo, |
||
328 | "grauExp", |
||
329 | $isl->infoagnocivo->grauexp, |
||
330 | true |
||
331 | ); |
||
332 | $ideEstabLot->appendChild($infoAgNocivo); |
||
333 | } |
||
334 | if (!empty($isl->infosimples)) { |
||
335 | $infoSimples = $this->dom->createElement("infoSimples"); |
||
336 | $this->dom->addChild( |
||
337 | $infoSimples, |
||
338 | "indSimples", |
||
339 | $isl->infosimples->indsimples, |
||
340 | true |
||
341 | ); |
||
342 | $ideEstabLot->appendChild($infoSimples); |
||
343 | } |
||
344 | $infoPerApur->appendChild($ideEstabLot); |
||
345 | } |
||
346 | $dmDev->appendChild($infoPerApur); |
||
347 | } |
||
348 | if (!empty($dm->infoperant)) { |
||
349 | $infoPerAnt = $this->dom->createElement("infoPerAnt"); |
||
350 | foreach ($dm->infoperant->ideadc as $adc) { |
||
351 | $ideADC = $this->dom->createElement("ideADC"); |
||
352 | $this->dom->addChild( |
||
353 | $ideADC, |
||
354 | "dtAcConv", |
||
355 | $adc->dtacconv, |
||
356 | true |
||
357 | ); |
||
358 | $this->dom->addChild( |
||
359 | $ideADC, |
||
360 | "tpAcConv", |
||
361 | $adc->tpacconv, |
||
362 | true |
||
363 | ); |
||
364 | $this->dom->addChild( |
||
365 | $ideADC, |
||
366 | "compAcConv", |
||
367 | !empty($adc->compacconv) ? $adc->compacconv : null, |
||
368 | false |
||
369 | ); |
||
370 | $this->dom->addChild( |
||
371 | $ideADC, |
||
372 | "dtEfAcConv", |
||
373 | !empty($adc->dtefacconv) ? $adc->dtefacconv : null, |
||
374 | false |
||
375 | ); |
||
376 | $this->dom->addChild( |
||
377 | $ideADC, |
||
378 | "dsc", |
||
379 | $adc->dsc, |
||
380 | true |
||
381 | ); |
||
382 | foreach ($adc->ideperiodo as $aper) { |
||
383 | $idePeriodo = $this->dom->createElement("idePeriodo"); |
||
384 | $this->dom->addChild( |
||
385 | $idePeriodo, |
||
386 | "perRef", |
||
387 | $aper->perref, |
||
388 | true |
||
389 | ); |
||
390 | foreach ($aper->ideestablot as $ael) { |
||
391 | $dmideEstabLot = $this->dom->createElement("ideEstabLot"); |
||
392 | $this->dom->addChild( |
||
393 | $dmideEstabLot, |
||
394 | "tpInsc", |
||
395 | $ael->tpinsc, |
||
396 | true |
||
397 | ); |
||
398 | $this->dom->addChild( |
||
399 | $dmideEstabLot, |
||
400 | "nrInsc", |
||
401 | $ael->nrinsc, |
||
402 | true |
||
403 | ); |
||
404 | $this->dom->addChild( |
||
405 | $dmideEstabLot, |
||
406 | "codLotacao", |
||
407 | $ael->codlotacao, |
||
408 | true |
||
409 | ); |
||
410 | foreach ($ael->detverbas as $adv) { |
||
411 | $dmdetVerbas = $this->dom->createElement("detVerbas"); |
||
412 | $this->dom->addChild( |
||
413 | $dmdetVerbas, |
||
414 | "codRubr", |
||
415 | $adv->codrubr, |
||
416 | true |
||
417 | ); |
||
418 | $this->dom->addChild( |
||
419 | $dmdetVerbas, |
||
420 | "ideTabRubr", |
||
421 | $adv->idetabrubr, |
||
422 | true |
||
423 | ); |
||
424 | $this->dom->addChild( |
||
425 | $dmdetVerbas, |
||
426 | "qtdRubr", |
||
427 | !empty($adv->qtdrubr) ? $adv->qtdrubr : null, |
||
428 | false |
||
429 | ); |
||
430 | $this->dom->addChild( |
||
431 | $dmdetVerbas, |
||
432 | "fatorRubr", |
||
433 | !empty($adv->fatorrubr) ? $adv->fatorrubr : null, |
||
434 | false |
||
435 | ); |
||
436 | $this->dom->addChild( |
||
437 | $dmdetVerbas, |
||
438 | "vrUnit", |
||
439 | !empty($adv->vrunit) ? $adv->vrunit : null, |
||
440 | false |
||
441 | ); |
||
442 | $this->dom->addChild( |
||
443 | $dmdetVerbas, |
||
444 | "vrRubr", |
||
445 | $adv->vrrubr, |
||
446 | true |
||
447 | ); |
||
448 | $dmideEstabLot->appendChild($dmdetVerbas); |
||
449 | } |
||
450 | if (!empty($ael->infoagnocivo)) { |
||
451 | $infoAgNocivo = $this->dom->createElement("infoAgNocivo"); |
||
452 | $this->dom->addChild( |
||
453 | $infoAgNocivo, |
||
454 | "grauExp", |
||
455 | $ael->infoagnocivo->grauexp, |
||
456 | true |
||
457 | ); |
||
458 | $dmideEstabLot->appendChild($infoAgNocivo); |
||
459 | } |
||
460 | if (!empty($ael->infosimples)) { |
||
461 | $infoSimples = $this->dom->createElement("infoSimples"); |
||
462 | $this->dom->addChild( |
||
463 | $infoSimples, |
||
464 | "indSimples", |
||
465 | $ael->infosimples->indsimples, |
||
466 | true |
||
467 | ); |
||
468 | $dmideEstabLot->appendChild($infoSimples); |
||
469 | } |
||
470 | $idePeriodo->appendChild($dmideEstabLot); |
||
471 | } |
||
472 | $ideADC->appendChild($idePeriodo); |
||
473 | } |
||
474 | $infoPerAnt->appendChild($ideADC); |
||
475 | } |
||
476 | $dmDev->appendChild($infoPerAnt); |
||
477 | } |
||
478 | if (!empty($dm->infotrabinterm)) { |
||
479 | foreach ($dm->infotrabinterm as $tin) { |
||
480 | $infoTrabInterm = $this->dom->createElement("infoTrabInterm"); |
||
481 | $this->dom->addChild( |
||
482 | $infoTrabInterm, |
||
483 | "codConv", |
||
484 | $tin->codconv, |
||
485 | true |
||
486 | ); |
||
487 | $dmDev->appendChild($infoTrabInterm); |
||
488 | } |
||
489 | } |
||
490 | $verbasResc->appendChild($dmDev); |
||
491 | } |
||
492 | if (!empty($this->std->verbasresc->procjudtrab)) { |
||
493 | foreach ($this->std->verbasresc->procjudtrab as $pjt) { |
||
494 | $procJudTrab = $this->dom->createElement("procJudTrab"); |
||
495 | $this->dom->addChild( |
||
496 | $procJudTrab, |
||
497 | "tpTrib", |
||
498 | $pjt->tptrib, |
||
499 | true |
||
500 | ); |
||
501 | $this->dom->addChild( |
||
502 | $procJudTrab, |
||
503 | "nrProcJud", |
||
504 | $pjt->nrprocjud, |
||
505 | true |
||
506 | ); |
||
507 | $this->dom->addChild( |
||
508 | $procJudTrab, |
||
509 | "codSusp", |
||
510 | !empty($pjt->codsusp) ? $pjt->codsusp : null, |
||
511 | false |
||
512 | ); |
||
513 | $verbasResc->appendChild($procJudTrab); |
||
514 | } |
||
515 | } |
||
516 | if (!empty($this->std->verbasresc->infomv)) { |
||
517 | $imv = $this->std->verbasresc->infomv; |
||
518 | $infoMV = $this->dom->createElement("infoMV"); |
||
519 | $this->dom->addChild( |
||
520 | $infoMV, |
||
521 | "indMV", |
||
522 | $imv->indmv, |
||
523 | true |
||
524 | ); |
||
525 | foreach ($imv->remunoutrempr as $roe) { |
||
526 | $remunOutrEmpr = $this->dom->createElement("remunOutrEmpr"); |
||
527 | $this->dom->addChild( |
||
528 | $remunOutrEmpr, |
||
529 | "tpInsc", |
||
530 | $roe->tpinsc, |
||
531 | true |
||
532 | ); |
||
533 | $this->dom->addChild( |
||
534 | $remunOutrEmpr, |
||
535 | "nrInsc", |
||
536 | $roe->nrinsc, |
||
537 | true |
||
538 | ); |
||
539 | $this->dom->addChild( |
||
540 | $remunOutrEmpr, |
||
541 | "codCateg", |
||
542 | $roe->codcateg, |
||
543 | true |
||
544 | ); |
||
545 | $this->dom->addChild( |
||
546 | $remunOutrEmpr, |
||
547 | "vlrRemunOE", |
||
548 | $roe->vlrremunoe, |
||
549 | true |
||
550 | ); |
||
551 | $infoMV->appendChild($remunOutrEmpr); |
||
552 | } |
||
553 | $verbasResc->appendChild($infoMV); |
||
554 | } |
||
555 | if (!empty($this->std->verbasresc->proccs)) { |
||
556 | $procCS = $this->dom->createElement("procCS"); |
||
557 | $this->dom->addChild( |
||
558 | $procCS, |
||
559 | "nrProcJud", |
||
560 | $this->std->verbasresc->proccs->nrprocjud, |
||
561 | true |
||
562 | ); |
||
563 | $verbasResc->appendChild($procCS); |
||
564 | } |
||
565 | $infoDeslig->appendChild($verbasResc); |
||
566 | } |
||
567 | if (!empty($this->std->quarentena)) { |
||
568 | $quarentena = $this->dom->createElement("quarentena"); |
||
569 | $this->dom->addChild( |
||
570 | $quarentena, |
||
571 | "dtFimQuar", |
||
572 | $this->std->quarentena->dtfimquar, |
||
573 | true |
||
574 | ); |
||
575 | $infoDeslig->appendChild($quarentena); |
||
576 | } |
||
577 | |||
578 | if (!empty($this->std->consigfgts)) { |
||
579 | foreach ($this->std->consigfgts as $cfg) { |
||
580 | $consigFGTS = $this->dom->createElement("consigFGTS"); |
||
581 | $this->dom->addChild( |
||
582 | $consigFGTS, |
||
583 | "insConsig", |
||
584 | $cfg->insconsig, |
||
585 | true |
||
586 | ); |
||
587 | $this->dom->addChild( |
||
588 | $consigFGTS, |
||
589 | "nrContr", |
||
590 | $cfg->nrcontr, |
||
591 | true |
||
592 | ); |
||
593 | $infoDeslig->appendChild($consigFGTS); |
||
594 | } |
||
595 | } |
||
596 | |||
597 | $this->node->appendChild($infoDeslig); |
||
598 | //finalização do xml |
||
599 | $this->eSocial->appendChild($this->node); |
||
600 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
601 | $this->sign(); |
||
602 | } |
||
603 | |||
612 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: