Conditions | 35 |
Paths | 24 |
Total Lines | 586 |
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 | $ideEvento = $this->dom->createElement("ideEvento"); |
||
14 | $this->dom->addChild( |
||
15 | $ideEvento, |
||
16 | "indApuracao", |
||
17 | $this->std->indapuracao, |
||
18 | true |
||
19 | ); |
||
20 | $this->dom->addChild( |
||
21 | $ideEvento, |
||
22 | "perApur", |
||
23 | $this->std->perapur, |
||
24 | true |
||
25 | ); |
||
26 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
27 | $infoCS = $this->dom->createElement("infoCS"); |
||
28 | $this->dom->addChild( |
||
29 | $infoCS, |
||
30 | "nrRecArqBase", |
||
31 | !empty($this->std->nrrecarqbase) ? $this->std->nrrecarqbase : null, |
||
32 | false |
||
33 | ); |
||
34 | $this->dom->addChild( |
||
35 | $infoCS, |
||
36 | "indExistInfo", |
||
37 | $this->std->indexistinfo, |
||
38 | true |
||
39 | ); |
||
40 | if (!empty($this->std->infocpseg)) { |
||
41 | $ips = $this->std->infocpseg; |
||
42 | $infoCPSeg = $this->dom->createElement("infoCPSeg"); |
||
43 | $this->dom->addChild( |
||
44 | $infoCPSeg, |
||
45 | "vrDescCP", |
||
46 | $ips->vrdesccp, |
||
47 | true |
||
48 | ); |
||
49 | $this->dom->addChild( |
||
50 | $infoCPSeg, |
||
51 | "vrCpSeg", |
||
52 | $ips->vrcpseg, |
||
53 | true |
||
54 | ); |
||
55 | $infoCS->appendChild($infoCPSeg); |
||
56 | } |
||
57 | $ict = $this->std->infocontrib; |
||
58 | $infoContrib = $this->dom->createElement("infoContrib"); |
||
59 | $this->dom->addChild( |
||
60 | $infoContrib, |
||
61 | "classTrib", |
||
62 | $ict->classtrib, |
||
63 | true |
||
64 | ); |
||
65 | if (!empty($ict->infopj)) { |
||
66 | $ipj = $ict->infopj; |
||
67 | $infoPJ = $this->dom->createElement("infoPJ"); |
||
68 | $this->dom->addChild( |
||
69 | $infoPJ, |
||
70 | "indCoop", |
||
71 | !empty($ipj->indcoop) ? $ipj->indcoop : null, |
||
72 | false |
||
73 | ); |
||
74 | $this->dom->addChild( |
||
75 | $infoPJ, |
||
76 | "indConstr", |
||
77 | $ipj->indconstr, |
||
78 | true |
||
79 | ); |
||
80 | $this->dom->addChild( |
||
81 | $infoPJ, |
||
82 | "indSubstPatr", |
||
83 | !empty($ipj->indsubstpatr) ? $ipj->indsubstpatr : null, |
||
84 | false |
||
85 | ); |
||
86 | $this->dom->addChild( |
||
87 | $infoPJ, |
||
88 | "percRedContrib", |
||
89 | !empty($ipj->percredcontrib) ? $ipj->percredcontrib : null, |
||
90 | false |
||
91 | ); |
||
92 | if (!empty($ipj->infoatconc)) { |
||
93 | $at = $ipj->infoatconc; |
||
94 | $infoAtConc = $this->dom->createElement("infoAtConc"); |
||
95 | $this->dom->addChild( |
||
96 | $infoAtConc, |
||
97 | "fatorMes", |
||
98 | $at->fatormes, |
||
99 | true |
||
100 | ); |
||
101 | $this->dom->addChild( |
||
102 | $infoAtConc, |
||
103 | "fator13", |
||
104 | $at->fator13, |
||
105 | true |
||
106 | ); |
||
107 | |||
108 | $infoPJ->appendChild($infoAtConc); |
||
109 | } |
||
110 | $infoContrib->appendChild($infoPJ); |
||
111 | } |
||
112 | $infoCS->appendChild($infoContrib); |
||
113 | if (!empty($this->std->ideestab)) { |
||
114 | foreach ($this->std->ideestab as $is) { |
||
115 | $ideEstab = $this->dom->createElement("ideEstab"); |
||
116 | $this->dom->addChild( |
||
117 | $ideEstab, |
||
118 | "tpInsc", |
||
119 | $is->tpinsc, |
||
120 | true |
||
121 | ); |
||
122 | $this->dom->addChild( |
||
123 | $ideEstab, |
||
124 | "nrInsc", |
||
125 | $is->nrinsc, |
||
126 | true |
||
127 | ); |
||
128 | if (!empty($is->infoestab)) { |
||
129 | $infoEstab = $this->dom->createElement("infoEstab"); |
||
130 | $this->dom->addChild( |
||
131 | $infoEstab, |
||
132 | "cnaePrep", |
||
133 | $is->infoestab->cnaeprep, |
||
134 | true |
||
135 | ); |
||
136 | $this->dom->addChild( |
||
137 | $infoEstab, |
||
138 | "aliqRat", |
||
139 | $is->infoestab->aliqrat, |
||
140 | true |
||
141 | ); |
||
142 | $this->dom->addChild( |
||
143 | $infoEstab, |
||
144 | "fap", |
||
145 | $is->infoestab->fap, |
||
146 | true |
||
147 | ); |
||
148 | $this->dom->addChild( |
||
149 | $infoEstab, |
||
150 | "aliqRatAjust", |
||
151 | $is->infoestab->aliqratajust, |
||
152 | true |
||
153 | ); |
||
154 | if (!empty($is->infoestab->infocomplobra)) { |
||
155 | $infoComplObra = $this->dom->createElement("infoComplObra"); |
||
156 | $this->dom->addChild( |
||
157 | $infoComplObra, |
||
158 | "indSubstPatrObra", |
||
159 | $is->infoestab->infocomplobra->indsubstpatrobra, |
||
160 | true |
||
161 | ); |
||
162 | $infoEstab->appendChild($infoComplObra); |
||
163 | } |
||
164 | $ideEstab->appendChild($infoEstab); |
||
165 | } |
||
166 | if (!empty($is->idelotacao)) { |
||
167 | foreach ($is->idelotacao as $id) { |
||
168 | $ideLotacao = $this->dom->createElement("ideLotacao"); |
||
169 | $this->dom->addChild( |
||
170 | $ideLotacao, |
||
171 | "codLotacao", |
||
172 | $id->codlotacao, |
||
173 | true |
||
174 | ); |
||
175 | $this->dom->addChild( |
||
176 | $ideLotacao, |
||
177 | "fpas", |
||
178 | $id->fpas, |
||
179 | true |
||
180 | ); |
||
181 | $this->dom->addChild( |
||
182 | $ideLotacao, |
||
183 | "codTercs", |
||
184 | $id->codtercs, |
||
185 | true |
||
186 | ); |
||
187 | $this->dom->addChild( |
||
188 | $ideLotacao, |
||
189 | "codTercsSusp", |
||
190 | !empty($id->codtercssusp) ? $id->codtercssusp : null, |
||
191 | false |
||
192 | ); |
||
193 | if (!empty($id->infotercsusp)) { |
||
194 | foreach ($id->infotercsusp as $tsus) { |
||
195 | $infoTercSusp = $this->dom->createElement("infoTercSusp"); |
||
196 | $this->dom->addChild( |
||
197 | $infoTercSusp, |
||
198 | "codTerc", |
||
199 | $tsus->codterc, |
||
200 | true |
||
201 | ); |
||
202 | $ideLotacao->appendChild($infoTercSusp); |
||
203 | } |
||
204 | } |
||
205 | if (!empty($id->infoemprparcial)) { |
||
206 | $infoEmprParcial = $this->dom->createElement("infoEmprParcial"); |
||
207 | $this->dom->addChild( |
||
208 | $infoEmprParcial, |
||
209 | "tpInscContrat", |
||
210 | $id->infoemprparcial->tpinsccontrat, |
||
211 | true |
||
212 | ); |
||
213 | $this->dom->addChild( |
||
214 | $infoEmprParcial, |
||
215 | "nrInscContrat", |
||
216 | $id->infoemprparcial->nrinsccontrat, |
||
217 | true |
||
218 | ); |
||
219 | $this->dom->addChild( |
||
220 | $infoEmprParcial, |
||
221 | "tpInscProp", |
||
222 | $id->infoemprparcial->tpinscprop, |
||
223 | true |
||
224 | ); |
||
225 | $this->dom->addChild( |
||
226 | $infoEmprParcial, |
||
227 | "nrInscProp", |
||
228 | $id->infoemprparcial->nrinscprop, |
||
229 | true |
||
230 | ); |
||
231 | $this->dom->addChild( |
||
232 | $infoEmprParcial, |
||
233 | "cnoObra", |
||
234 | $id->infoemprparcial->cnoobra, |
||
235 | true |
||
236 | ); |
||
237 | $ideLotacao->appendChild($infoEmprParcial); |
||
238 | } |
||
239 | if (!empty($id->dadosopport)) { |
||
240 | $dadosOpPort = $this->dom->createElement("dadosOpPort"); |
||
241 | $this->dom->addChild( |
||
242 | $dadosOpPort, |
||
243 | "cnpjOpPortuario", |
||
244 | $id->dadosopport->cnpjopportuario, |
||
245 | true |
||
246 | ); |
||
247 | $this->dom->addChild( |
||
248 | $dadosOpPort, |
||
249 | "aliqRat", |
||
250 | $id->dadosopport->aliqrat, |
||
251 | true |
||
252 | ); |
||
253 | $this->dom->addChild( |
||
254 | $dadosOpPort, |
||
255 | "fap", |
||
256 | $id->dadosopport->fap, |
||
257 | true |
||
258 | ); |
||
259 | $this->dom->addChild( |
||
260 | $dadosOpPort, |
||
261 | "aliqRatAjust", |
||
262 | $id->dadosopport->aliqratajust, |
||
263 | true |
||
264 | ); |
||
265 | $ideLotacao->appendChild($dadosOpPort); |
||
266 | } |
||
267 | if (!empty($id->basesremun)) { |
||
268 | foreach ($id->basesremun as $br) { |
||
269 | $basesRemun = $this->dom->createElement("basesRemun"); |
||
270 | $this->dom->addChild( |
||
271 | $basesRemun, |
||
272 | "indIncid", |
||
273 | $br->indincid, |
||
274 | true |
||
275 | ); |
||
276 | $this->dom->addChild( |
||
277 | $basesRemun, |
||
278 | "codCateg", |
||
279 | $br->codcateg, |
||
280 | true |
||
281 | ); |
||
282 | $basesCp = $this->dom->createElement("basesCp"); |
||
283 | $this->dom->addChild( |
||
284 | $basesCp, |
||
285 | "vrBcCp00", |
||
286 | $br->basescp->vrbccp00, |
||
287 | true |
||
288 | ); |
||
289 | $this->dom->addChild( |
||
290 | $basesCp, |
||
291 | "vrBcCp15", |
||
292 | $br->basescp->vrbccp15, |
||
293 | true |
||
294 | ); |
||
295 | $this->dom->addChild( |
||
296 | $basesCp, |
||
297 | "vrBcCp20", |
||
298 | $br->basescp->vrbccp20, |
||
299 | true |
||
300 | ); |
||
301 | $this->dom->addChild( |
||
302 | $basesCp, |
||
303 | "vrBcCp25", |
||
304 | $br->basescp->vrbccp25, |
||
305 | true |
||
306 | ); |
||
307 | $this->dom->addChild( |
||
308 | $basesCp, |
||
309 | "vrSuspBcCp00", |
||
310 | $br->basescp->vrsuspbccp00, |
||
311 | true |
||
312 | ); |
||
313 | $this->dom->addChild( |
||
314 | $basesCp, |
||
315 | "vrSuspBcCp15", |
||
316 | $br->basescp->vrsuspbccp15, |
||
317 | true |
||
318 | ); |
||
319 | $this->dom->addChild( |
||
320 | $basesCp, |
||
321 | "vrSuspBcCp20", |
||
322 | $br->basescp->vrsuspbccp20, |
||
323 | true |
||
324 | ); |
||
325 | $this->dom->addChild( |
||
326 | $basesCp, |
||
327 | "vrSuspBcCp25", |
||
328 | $br->basescp->vrsuspbccp25, |
||
329 | true |
||
330 | ); |
||
331 | $this->dom->addChild( |
||
332 | $basesCp, |
||
333 | "vrDescSest", |
||
334 | $br->basescp->vrdescsest, |
||
335 | true |
||
336 | ); |
||
337 | $this->dom->addChild( |
||
338 | $basesCp, |
||
339 | "vrCalcSest", |
||
340 | $br->basescp->vrcalcsest, |
||
341 | true |
||
342 | ); |
||
343 | $this->dom->addChild( |
||
344 | $basesCp, |
||
345 | "vrDescSenat", |
||
346 | $br->basescp->vrdescsenat, |
||
347 | true |
||
348 | ); |
||
349 | $this->dom->addChild( |
||
350 | $basesCp, |
||
351 | "vrCalcSenat", |
||
352 | $br->basescp->vrcalcsenat, |
||
353 | true |
||
354 | ); |
||
355 | $this->dom->addChild( |
||
356 | $basesCp, |
||
357 | "vrSalFam", |
||
358 | $br->basescp->vrsalfam, |
||
359 | true |
||
360 | ); |
||
361 | $this->dom->addChild( |
||
362 | $basesCp, |
||
363 | "vrSalMat", |
||
364 | $br->basescp->vrsalmat, |
||
365 | true |
||
366 | ); |
||
367 | $basesRemun->appendChild($basesCp); |
||
368 | $ideLotacao->appendChild($basesRemun); |
||
369 | } |
||
370 | } |
||
371 | if (!empty($id->basesavnport)) { |
||
372 | $basesAvNPort = $this->dom->createElement("basesAvNPort"); |
||
373 | $this->dom->addChild( |
||
374 | $basesAvNPort, |
||
375 | "vrBcCp00", |
||
376 | $id->basesavnport->vrbccp00, |
||
377 | true |
||
378 | ); |
||
379 | $this->dom->addChild( |
||
380 | $basesAvNPort, |
||
381 | "vrBcCp15", |
||
382 | $id->basesavnport->vrbccp15, |
||
383 | true |
||
384 | ); |
||
385 | $this->dom->addChild( |
||
386 | $basesAvNPort, |
||
387 | "vrBcCp20", |
||
388 | $id->basesavnport->vrbccp20, |
||
389 | true |
||
390 | ); |
||
391 | $this->dom->addChild( |
||
392 | $basesAvNPort, |
||
393 | "vrBcCp25", |
||
394 | $id->basesavnport->vrbccp25, |
||
395 | true |
||
396 | ); |
||
397 | $this->dom->addChild( |
||
398 | $basesAvNPort, |
||
399 | "vrBcCp13", |
||
400 | $id->basesavnport->vrbccp13, |
||
401 | true |
||
402 | ); |
||
403 | $this->dom->addChild( |
||
404 | $basesAvNPort, |
||
405 | "vrBcFgts", |
||
406 | $id->basesavnport->vrbcfgts, |
||
407 | true |
||
408 | ); |
||
409 | $this->dom->addChild( |
||
410 | $basesAvNPort, |
||
411 | "vrDescCP", |
||
412 | $id->basesavnport->vrdesccp, |
||
413 | true |
||
414 | ); |
||
415 | $ideLotacao->appendChild($basesAvNPort); |
||
416 | } |
||
417 | if (!empty($id->infosubstpatropport)) { |
||
418 | foreach ($id->infosubstpatropport as $ipp) { |
||
419 | $infoSubstPatrOpPort = $this->dom->createElement("infoSubstPatrOpPort"); |
||
420 | $this->dom->addChild( |
||
421 | $infoSubstPatrOpPort, |
||
422 | "cnpjOpPortuario", |
||
423 | $ipp->cnpjopportuario, |
||
424 | true |
||
425 | ); |
||
426 | $ideLotacao->appendChild($infoSubstPatrOpPort); |
||
427 | } |
||
428 | } |
||
429 | $ideEstab->appendChild($ideLotacao); |
||
430 | } |
||
431 | } |
||
432 | if (!empty($is->basesaquis)) { |
||
433 | foreach ($is->basesaquis as $bq) { |
||
434 | $basesAquis = $this->dom->createElement("basesAquis"); |
||
435 | $this->dom->addChild( |
||
436 | $basesAquis, |
||
437 | "indAquis", |
||
438 | $bq->indaquis, |
||
439 | true |
||
440 | ); |
||
441 | $this->dom->addChild( |
||
442 | $basesAquis, |
||
443 | "vlrAquis", |
||
444 | $bq->vlraquis, |
||
445 | true |
||
446 | ); |
||
447 | $this->dom->addChild( |
||
448 | $basesAquis, |
||
449 | "vrCPDescPR", |
||
450 | $bq->vrcpdescpr, |
||
451 | true |
||
452 | ); |
||
453 | $this->dom->addChild( |
||
454 | $basesAquis, |
||
455 | "vrCPNRet", |
||
456 | $bq->vrcpnret, |
||
457 | true |
||
458 | ); |
||
459 | $this->dom->addChild( |
||
460 | $basesAquis, |
||
461 | "vrRatNRet", |
||
462 | $bq->vrratnret, |
||
463 | true |
||
464 | ); |
||
465 | $this->dom->addChild( |
||
466 | $basesAquis, |
||
467 | "vrSenarNRet", |
||
468 | $bq->vrsenarnret, |
||
469 | true |
||
470 | ); |
||
471 | $this->dom->addChild( |
||
472 | $basesAquis, |
||
473 | "vrCPCalcPR", |
||
474 | $bq->vrcpcalcpr, |
||
475 | true |
||
476 | ); |
||
477 | $this->dom->addChild( |
||
478 | $basesAquis, |
||
479 | "vrRatDescPR", |
||
480 | $bq->vrratdescpr, |
||
481 | true |
||
482 | ); |
||
483 | $this->dom->addChild( |
||
484 | $basesAquis, |
||
485 | "vrRatCalcPR", |
||
486 | $bq->vrratcalcpr, |
||
487 | true |
||
488 | ); |
||
489 | $this->dom->addChild( |
||
490 | $basesAquis, |
||
491 | "vrSenarDesc", |
||
492 | $bq->vrsenardesc, |
||
493 | true |
||
494 | ); |
||
495 | $this->dom->addChild( |
||
496 | $basesAquis, |
||
497 | "vrSenarCalc", |
||
498 | $bq->vrsenarcalc, |
||
499 | true |
||
500 | ); |
||
501 | $ideEstab->appendChild($basesAquis); |
||
502 | } |
||
503 | } |
||
504 | if (!empty($is->basescomerc)) { |
||
505 | foreach ($is->basescomerc as $bc) { |
||
506 | $basesComerc = $this->dom->createElement("basesComerc"); |
||
507 | $this->dom->addChild( |
||
508 | $basesComerc, |
||
509 | "indComerc", |
||
510 | $bc->indcomerc, |
||
511 | true |
||
512 | ); |
||
513 | $this->dom->addChild( |
||
514 | $basesComerc, |
||
515 | "vrBcComPR", |
||
516 | $bc->vrbccompr, |
||
517 | true |
||
518 | ); |
||
519 | $this->dom->addChild( |
||
520 | $basesComerc, |
||
521 | "vrCPSusp", |
||
522 | !empty($bc->vrcpsusp) ? $bc->vrcpsusp : null, |
||
523 | false |
||
524 | ); |
||
525 | $this->dom->addChild( |
||
526 | $basesComerc, |
||
527 | "vrRatSusp", |
||
528 | !empty($bc->vrratsusp) ? $bc->vrratsusp : null, |
||
529 | false |
||
530 | ); |
||
531 | $this->dom->addChild( |
||
532 | $basesComerc, |
||
533 | "vrSenarSusp", |
||
534 | !empty($bc->vrsenarsusp) ? $bc->vrsenarsusp : null, |
||
535 | false |
||
536 | ); |
||
537 | $ideEstab->appendChild($basesComerc); |
||
538 | } |
||
539 | } |
||
540 | if (!empty($is->infocrestab)) { |
||
541 | foreach ($is->infocrestab as $cre) { |
||
542 | $infoCREstab = $this->dom->createElement("infoCREstab"); |
||
543 | $this->dom->addChild( |
||
544 | $infoCREstab, |
||
545 | "tpCR", |
||
546 | $cre->tpcr, |
||
547 | true |
||
548 | ); |
||
549 | $this->dom->addChild( |
||
550 | $infoCREstab, |
||
551 | "vrCR", |
||
552 | $cre->vrcr, |
||
553 | true |
||
554 | ); |
||
555 | $this->dom->addChild( |
||
556 | $infoCREstab, |
||
557 | "vrSuspCR", |
||
558 | $cre->vrsuspcr, |
||
559 | true |
||
560 | ); |
||
561 | $ideEstab->appendChild($infoCREstab); |
||
562 | } |
||
563 | } |
||
564 | $infoCS->appendChild($ideEstab); |
||
565 | } |
||
566 | } |
||
567 | if (!empty($this->std->infocrcontrib)) { |
||
568 | foreach ($this->std->infocrcontrib as $ic) { |
||
569 | $infoCRContrib = $this->dom->createElement("infoCRContrib"); |
||
570 | $this->dom->addChild( |
||
571 | $infoCRContrib, |
||
572 | "tpCR", |
||
573 | $ic->tpcr, |
||
574 | true |
||
575 | ); |
||
576 | $this->dom->addChild( |
||
577 | $infoCRContrib, |
||
578 | "vrCR", |
||
579 | $ic->vrcr, |
||
580 | true |
||
581 | ); |
||
582 | $this->dom->addChild( |
||
583 | $infoCRContrib, |
||
584 | "vrCRSusp", |
||
585 | $ic->vrcrsusp, |
||
586 | true |
||
587 | ); |
||
588 | $infoCS->appendChild($infoCRContrib); |
||
589 | } |
||
590 | } |
||
591 | $this->node->appendChild($infoCS); |
||
592 | $this->eSocial->appendChild($this->node); |
||
593 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
594 | $this->sign(); |
||
595 | } |
||
596 | |||
605 |
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: