Conditions | 53 |
Paths | 216 |
Total Lines | 558 |
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 | "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, |
||
44 | true |
||
45 | ); |
||
46 | $this->dom->addChild( |
||
47 | $ideEvento, |
||
48 | "procEmi", |
||
49 | $this->procEmi, |
||
50 | true |
||
51 | ); |
||
52 | $this->dom->addChild( |
||
53 | $ideEvento, |
||
54 | "verProc", |
||
55 | $this->verProc, |
||
56 | true |
||
57 | ); |
||
58 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
59 | $ide = $this->dom->createElement("ideTrabalhador"); |
||
60 | $this->dom->addChild( |
||
61 | $ide, |
||
62 | "cpfTrab", |
||
63 | $this->std->cpftrab, |
||
64 | true |
||
65 | ); |
||
66 | $this->dom->addChild( |
||
67 | $ide, |
||
68 | "nisTrab", |
||
69 | !empty($this->std->nistrab) ? $this->std->nistrab : null, |
||
70 | false |
||
71 | ); |
||
72 | if (!empty($this->std->infomv)) { |
||
73 | $info = $this->dom->createElement("infoMV"); |
||
74 | $this->dom->addChild( |
||
75 | $info, |
||
76 | "indMV", |
||
77 | $this->std->infomv->indmv, |
||
78 | true |
||
79 | ); |
||
80 | if (!empty($this->std->infomv->remunoutrempr)) { |
||
81 | foreach ($this->std->infomv->remunoutrempr as $remo) { |
||
82 | $remunOutrEmpr = $this->dom->createElement("remunOutrEmpr"); |
||
83 | $this->dom->addChild( |
||
84 | $remunOutrEmpr, |
||
85 | "tpInsc", |
||
86 | $remo->tpinsc, |
||
87 | true |
||
88 | ); |
||
89 | $this->dom->addChild( |
||
90 | $remunOutrEmpr, |
||
91 | "nrInsc", |
||
92 | $remo->nrinsc, |
||
93 | true |
||
94 | ); |
||
95 | $this->dom->addChild( |
||
96 | $remunOutrEmpr, |
||
97 | "codCateg", |
||
98 | $remo->codcateg, |
||
99 | true |
||
100 | ); |
||
101 | $this->dom->addChild( |
||
102 | $remunOutrEmpr, |
||
103 | "vlrRemunOE", |
||
104 | $remo->vlrremunoe, |
||
105 | true |
||
106 | ); |
||
107 | $info->appendChild($remunOutrEmpr); |
||
108 | } |
||
109 | $ide->appendChild($info); |
||
110 | } |
||
111 | } |
||
112 | if (!empty($this->std->infocomplem)) { |
||
113 | $ic = $this->std->infocomplem; |
||
114 | $infoComplem = $this->dom->createElement("infoComplem"); |
||
115 | $this->dom->addChild( |
||
116 | $infoComplem, |
||
117 | "nmTrab", |
||
118 | $ic->nmtrab, |
||
119 | true |
||
120 | ); |
||
121 | $this->dom->addChild( |
||
122 | $infoComplem, |
||
123 | "dtNascto", |
||
124 | $ic->dtnascto, |
||
125 | true |
||
126 | ); |
||
127 | if (!empty($ic->sucessaovinc)) { |
||
128 | $sucessaoVinc = $this->dom->createElement("sucessaoVinc"); |
||
129 | $this->dom->addChild( |
||
130 | $sucessaoVinc, |
||
131 | "tpInscAnt", |
||
132 | $ic->sucessaovinc->tpinscant, |
||
133 | true |
||
134 | ); |
||
135 | $this->dom->addChild( |
||
136 | $sucessaoVinc, |
||
137 | "cnpjEmpregAnt", |
||
138 | $ic->sucessaovinc->cnpjempregant, |
||
139 | true |
||
140 | ); |
||
141 | $this->dom->addChild( |
||
142 | $sucessaoVinc, |
||
143 | "matricAnt", |
||
144 | !empty($ic->sucessaovinc->matricant) ? $ic->sucessaovinc->matricant : null, |
||
145 | false |
||
146 | ); |
||
147 | $this->dom->addChild( |
||
148 | $sucessaoVinc, |
||
149 | "dtAdm", |
||
150 | $ic->sucessaovinc->dtadm, |
||
151 | true |
||
152 | ); |
||
153 | $this->dom->addChild( |
||
154 | $sucessaoVinc, |
||
155 | "observacao", |
||
156 | !empty($ic->observacao) ? $ic->observacao : null, |
||
157 | false |
||
158 | ); |
||
159 | $infoComplem->appendChild($sucessaoVinc); |
||
160 | } |
||
161 | $ide->appendChild($infoComplem); |
||
162 | } |
||
163 | if (!empty($this->std->procjudtrab)) { |
||
164 | foreach ($this->std->procjudtrab as $proc) { |
||
165 | $procJudTrab = $this->dom->createElement("procJudTrab"); |
||
166 | $this->dom->addChild( |
||
167 | $procJudTrab, |
||
168 | "tpTrib", |
||
169 | $proc->tptrib, |
||
170 | true |
||
171 | ); |
||
172 | $this->dom->addChild( |
||
173 | $procJudTrab, |
||
174 | "nrProcJud", |
||
175 | $proc->nrprocjud, |
||
176 | true |
||
177 | ); |
||
178 | $this->dom->addChild( |
||
179 | $procJudTrab, |
||
180 | "codSusp", |
||
181 | !empty($proc->codsusp) ? $proc->codsusp : null, |
||
182 | false |
||
183 | ); |
||
184 | $ide->appendChild($procJudTrab); |
||
185 | } |
||
186 | } |
||
187 | if (!empty($this->std->infointerm)) { |
||
188 | $infoInterm = $this->dom->createElement("infoInterm"); |
||
189 | $this->dom->addChild( |
||
190 | $infoInterm, |
||
191 | "qtdDiasInterm", |
||
192 | $this->std->infointerm->qtddiasinterm, |
||
193 | true |
||
194 | ); |
||
195 | $ide->appendChild($infoInterm); |
||
196 | } |
||
197 | $this->node->appendChild($ide); |
||
198 | foreach ($this->std->dmdev as $dm) { |
||
199 | $dmDev = $this->dom->createElement("dmDev"); |
||
200 | $this->dom->addChild( |
||
201 | $dmDev, |
||
202 | "ideDmDev", |
||
203 | $dm->idedmdev, |
||
204 | true |
||
205 | ); |
||
206 | $this->dom->addChild( |
||
207 | $dmDev, |
||
208 | "codCateg", |
||
209 | $dm->codcateg, |
||
210 | true |
||
211 | ); |
||
212 | if (!empty($dm->ideestablot)) { |
||
213 | $infoPerApur = $this->dom->createElement("infoPerApur"); |
||
214 | foreach ($dm->ideestablot as $idsl) { |
||
215 | $ideEstabLot = $this->dom->createElement("ideEstabLot"); |
||
216 | $this->dom->addChild( |
||
217 | $ideEstabLot, |
||
218 | "tpInsc", |
||
219 | $idsl->tpinsc, |
||
220 | true |
||
221 | ); |
||
222 | $this->dom->addChild( |
||
223 | $ideEstabLot, |
||
224 | "nrInsc", |
||
225 | $idsl->nrinsc, |
||
226 | true |
||
227 | ); |
||
228 | $this->dom->addChild( |
||
229 | $ideEstabLot, |
||
230 | "codLotacao", |
||
231 | $idsl->codlotacao, |
||
232 | true |
||
233 | ); |
||
234 | $this->dom->addChild( |
||
235 | $ideEstabLot, |
||
236 | "qtdDiasAv", |
||
237 | !empty($idsl->qtddiasav) ? $idsl->qtddiasav : null, |
||
238 | false |
||
239 | ); |
||
240 | foreach ($idsl->remunperapur as $rpa) { |
||
241 | $remunPerApur = $this->dom->createElement("remunPerApur"); |
||
242 | $this->dom->addChild( |
||
243 | $remunPerApur, |
||
244 | "matricula", |
||
245 | !empty($rpa->matricula) ? $rpa->matricula : null, |
||
246 | false |
||
247 | ); |
||
248 | $this->dom->addChild( |
||
249 | $remunPerApur, |
||
250 | "indSimples", |
||
251 | !empty($rpa->indsimples) ? $rpa->indsimples : null, |
||
252 | false |
||
253 | ); |
||
254 | foreach ($rpa->itensremun as $itemr) { |
||
255 | $itensRemun = $this->dom->createElement("itensRemun"); |
||
256 | $this->dom->addChild( |
||
257 | $itensRemun, |
||
258 | "codRubr", |
||
259 | $itemr->codrubr, |
||
260 | true |
||
261 | ); |
||
262 | $this->dom->addChild( |
||
263 | $itensRemun, |
||
264 | "ideTabRubr", |
||
265 | $itemr->idetabrubr, |
||
266 | true |
||
267 | ); |
||
268 | $this->dom->addChild( |
||
269 | $itensRemun, |
||
270 | "qtdRubr", |
||
271 | !empty($itemr->qtdrubr) ? $itemr->qtdrubr : null, |
||
272 | false |
||
273 | ); |
||
274 | $this->dom->addChild( |
||
275 | $itensRemun, |
||
276 | "fatorRubr", |
||
277 | !empty($itemr->fatorrubr) ? $itemr->fatorrubr : null, |
||
278 | false |
||
279 | ); |
||
280 | $this->dom->addChild( |
||
281 | $itensRemun, |
||
282 | "vrUnit", |
||
283 | !empty($itemr->vrunit) ? $itemr->vrunit : null, |
||
284 | false |
||
285 | ); |
||
286 | $this->dom->addChild( |
||
287 | $itensRemun, |
||
288 | "vrRubr", |
||
289 | $itemr->vrrubr, |
||
290 | true |
||
291 | ); |
||
292 | $remunPerApur->appendChild($itensRemun); |
||
293 | } |
||
294 | if (!empty($rpa->detoper)) { |
||
295 | $infoSaudeColet = $this->dom->createElement("infoSaudeColet"); |
||
296 | foreach ($rpa->detoper as $dop) { |
||
297 | $detOper = $this->dom->createElement("detOper"); |
||
298 | $this->dom->addChild( |
||
299 | $detOper, |
||
300 | "cnpjOper", |
||
301 | $dop->cnpjoper, |
||
302 | true |
||
303 | ); |
||
304 | $this->dom->addChild( |
||
305 | $detOper, |
||
306 | "regANS", |
||
307 | $dop->regans, |
||
308 | true |
||
309 | ); |
||
310 | $this->dom->addChild( |
||
311 | $detOper, |
||
312 | "vrPgTit", |
||
313 | $dop->vrpgtit, |
||
314 | true |
||
315 | ); |
||
316 | if (!empty($dop->detplano)) { |
||
317 | foreach ($dop->detplano as $pl) { |
||
318 | $detPlano = $this->dom->createElement("detPlano"); |
||
319 | $this->dom->addChild( |
||
320 | $detPlano, |
||
321 | "tpDep", |
||
322 | $pl->tpdep, |
||
323 | true |
||
324 | ); |
||
325 | $this->dom->addChild( |
||
326 | $detPlano, |
||
327 | "cpfDep", |
||
328 | !empty($pl->cpfdep) ? $pl->cpfdep : null, |
||
329 | false |
||
330 | ); |
||
331 | $this->dom->addChild( |
||
332 | $detPlano, |
||
333 | "nmDep", |
||
334 | $pl->nmdep, |
||
335 | true |
||
336 | ); |
||
337 | $this->dom->addChild( |
||
338 | $detPlano, |
||
339 | "dtNascto", |
||
340 | $pl->dtnascto, |
||
341 | true |
||
342 | ); |
||
343 | $this->dom->addChild( |
||
344 | $detPlano, |
||
345 | "vlrPgDep", |
||
346 | $pl->vlrpgdep, |
||
347 | true |
||
348 | ); |
||
349 | $detOper->appendChild($detPlano); |
||
350 | } |
||
351 | } |
||
352 | $infoSaudeColet->appendChild($detOper); |
||
353 | } |
||
354 | $remunPerApur->appendChild($infoSaudeColet); |
||
355 | } |
||
356 | if (!empty($rpa->infoagnocivo)) { |
||
357 | $infoAgNocivo = $this->dom->createElement("infoAgNocivo"); |
||
358 | $this->dom->addChild( |
||
359 | $infoAgNocivo, |
||
360 | "grauExp", |
||
361 | $rpa->infoagnocivo->grauexp, |
||
362 | true |
||
363 | ); |
||
364 | $remunPerApur->appendChild($infoAgNocivo); |
||
365 | } |
||
366 | |||
367 | if (!empty($rpa->infotrabinterm)) { |
||
368 | foreach ($rpa->infotrabinterm as $iti) { |
||
369 | $infoTrabInterm = $this->dom->createElement("infoTrabInterm"); |
||
370 | $this->dom->addChild( |
||
371 | $infoTrabInterm, |
||
372 | "codConv", |
||
373 | $iti->codconv, |
||
374 | true |
||
375 | ); |
||
376 | $remunPerApur->appendChild($infoTrabInterm); |
||
377 | } |
||
378 | } |
||
379 | |||
380 | $ideEstabLot->appendChild($remunPerApur); |
||
381 | } |
||
382 | $infoPerApur->appendChild($ideEstabLot); |
||
383 | } |
||
384 | $dmDev->appendChild($infoPerApur); |
||
385 | if (!empty($dm->ideadc)) { |
||
386 | $infoPerAnt = $this->dom->createElement("infoPerAnt"); |
||
387 | foreach ($dm->ideadc as $adc) { |
||
388 | $ideADC = $this->dom->createElement("ideADC"); |
||
389 | $this->dom->addChild( |
||
390 | $ideADC, |
||
391 | "dtAcConv", |
||
392 | !empty($adc->dtacconv) ? $adc->dtacconv : null, |
||
393 | false |
||
394 | ); |
||
395 | $this->dom->addChild( |
||
396 | $ideADC, |
||
397 | "tpAcConv", |
||
398 | $adc->tpacconv, |
||
399 | true |
||
400 | ); |
||
401 | $this->dom->addChild( |
||
402 | $ideADC, |
||
403 | "compAcConv", |
||
404 | !empty($adc->compacconv) ? $adc->compacconv : null, |
||
405 | false |
||
406 | ); |
||
407 | $this->dom->addChild( |
||
408 | $ideADC, |
||
409 | "dtEfAcConv", |
||
410 | !empty($adc->dtefacconv) ? $adc->dtefacconv : null, |
||
411 | false |
||
412 | ); |
||
413 | $this->dom->addChild( |
||
414 | $ideADC, |
||
415 | "dsc", |
||
416 | $adc->dsc, |
||
417 | true |
||
418 | ); |
||
419 | $this->dom->addChild( |
||
420 | $ideADC, |
||
421 | "remunSuc", |
||
422 | $adc->remunsuc, |
||
423 | true |
||
424 | ); |
||
425 | foreach ($adc->ideperiodo as $idp) { |
||
426 | $idePeriodo = $this->dom->createElement("idePeriodo"); |
||
427 | $this->dom->addChild( |
||
428 | $idePeriodo, |
||
429 | "perRef", |
||
430 | $idp->perref, |
||
431 | true |
||
432 | ); |
||
433 | foreach ($idp->ideestablot as $idl) { |
||
434 | $ideEstabLot = $this->dom->createElement("ideEstabLot"); |
||
435 | $this->dom->addChild( |
||
436 | $ideEstabLot, |
||
437 | "tpInsc", |
||
438 | $idl->tpinsc, |
||
439 | true |
||
440 | ); |
||
441 | $this->dom->addChild( |
||
442 | $ideEstabLot, |
||
443 | "nrInsc", |
||
444 | $idl->nrinsc, |
||
445 | true |
||
446 | ); |
||
447 | $this->dom->addChild( |
||
448 | $ideEstabLot, |
||
449 | "codLotacao", |
||
450 | $idl->codlotacao, |
||
451 | true |
||
452 | ); |
||
453 | foreach ($idl->remunperant as $rpr) { |
||
454 | $remunPerAnt = $this->dom->createElement("remunPerAnt"); |
||
455 | $this->dom->addChild( |
||
456 | $remunPerAnt, |
||
457 | "matricula", |
||
458 | !empty($rpr->matricula) ? $rpr->matricula : null, |
||
459 | false |
||
460 | ); |
||
461 | $this->dom->addChild( |
||
462 | $remunPerAnt, |
||
463 | "indSimples", |
||
464 | !empty($rpr->indsimples) ? $rpr->indsimples : null, |
||
465 | false |
||
466 | ); |
||
467 | foreach ($rpr->itensremun as $irem) { |
||
468 | $itensRemun = $this->dom->createElement("itensRemun"); |
||
469 | $this->dom->addChild( |
||
470 | $itensRemun, |
||
471 | "codRubr", |
||
472 | $irem->codrubr, |
||
473 | true |
||
474 | ); |
||
475 | $this->dom->addChild( |
||
476 | $itensRemun, |
||
477 | "ideTabRubr", |
||
478 | $irem->idetabrubr, |
||
479 | true |
||
480 | ); |
||
481 | $this->dom->addChild( |
||
482 | $itensRemun, |
||
483 | "qtdRubr", |
||
484 | !empty($irem->qtdrubr) ? $irem->qtdrubr : null, |
||
485 | false |
||
486 | ); |
||
487 | $this->dom->addChild( |
||
488 | $itensRemun, |
||
489 | "fatorRubr", |
||
490 | !empty($irem->fatorrubr) ? $irem->fatorrubr : null, |
||
491 | false |
||
492 | ); |
||
493 | $this->dom->addChild( |
||
494 | $itensRemun, |
||
495 | "vrUnit", |
||
496 | !empty($irem->vrunit) ? $irem->vrunit : null, |
||
497 | false |
||
498 | ); |
||
499 | $this->dom->addChild( |
||
500 | $itensRemun, |
||
501 | "vrRubr", |
||
502 | $irem->vrrubr, |
||
503 | true |
||
504 | ); |
||
505 | $remunPerAnt->appendChild($itensRemun); |
||
506 | } |
||
507 | if (!empty($rpr->infoagnocivo)) { |
||
508 | $infoAgNocivo = $this->dom->createElement("infoAgNocivo"); |
||
509 | $this->dom->addChild( |
||
510 | $infoAgNocivo, |
||
511 | "grauExp", |
||
512 | $rpr->infoagnocivo->grauexp, |
||
513 | true |
||
514 | ); |
||
515 | $remunPerAnt->appendChild($infoAgNocivo); |
||
516 | } |
||
517 | if (!empty($rpr->infotrabinterm)) { |
||
518 | foreach ($rpr->infotrabinterm as $iti) { |
||
519 | $infoTrabInterm = $this->dom->createElement("infoTrabInterm"); |
||
520 | $this->dom->addChild( |
||
521 | $infoTrabInterm, |
||
522 | "codConv", |
||
523 | $iti->codconv, |
||
524 | true |
||
525 | ); |
||
526 | $remunPerAnt->appendChild($infoTrabInterm); |
||
527 | } |
||
528 | } |
||
529 | $ideEstabLot->appendChild($remunPerAnt); |
||
530 | } |
||
531 | $idePeriodo->appendChild($ideEstabLot); |
||
532 | } |
||
533 | $ideADC->appendChild($idePeriodo); |
||
534 | } |
||
535 | $infoPerAnt->appendChild($ideADC); |
||
536 | } |
||
537 | $dmDev->appendChild($infoPerAnt); |
||
538 | } |
||
539 | if (!empty($dm->infocomplcont)) { |
||
540 | $infoComplCont = $this->dom->createElement("infoComplCont"); |
||
541 | $this->dom->addChild( |
||
542 | $infoComplCont, |
||
543 | "codCBO", |
||
544 | $dm->infocomplcont->codcbo, |
||
545 | true |
||
546 | ); |
||
547 | $this->dom->addChild( |
||
548 | $infoComplCont, |
||
549 | "natAtividade", |
||
550 | !empty($dm->infocomplcont->natatividade) ? $dm->infocomplcont->natatividade : null, |
||
551 | false |
||
552 | ); |
||
553 | $this->dom->addChild( |
||
554 | $infoComplCont, |
||
555 | "qtdDiasTrab", |
||
556 | !empty($dm->infocomplcont->qtddiastrab) ? $dm->infocomplcont->qtddiastrab : null, |
||
557 | false |
||
558 | ); |
||
559 | $dmDev->appendChild($infoComplCont); |
||
560 | } |
||
561 | } |
||
562 | $this->node->appendChild($dmDev); |
||
563 | } |
||
564 | $this->eSocial->appendChild($this->node); |
||
565 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
566 | $this->sign(); |
||
567 | } |
||
568 | |||
577 |
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: