Conditions | 84 |
Paths | > 20000 |
Total Lines | 1188 |
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 | "indRetif", |
||
17 | $this->std->indretif, |
||
18 | true |
||
19 | ); |
||
20 | $this->dom->addChild( |
||
21 | $ideEvento, |
||
22 | "nrRecibo", |
||
23 | ! empty($this->std->nrrecibo) ? $this->std->nrrecibo : null, |
||
24 | false |
||
25 | ); |
||
26 | $this->dom->addChild( |
||
27 | $ideEvento, |
||
28 | "tpAmb", |
||
29 | $this->tpAmb, |
||
30 | true |
||
31 | ); |
||
32 | $this->dom->addChild( |
||
33 | $ideEvento, |
||
34 | "procEmi", |
||
35 | $this->procEmi, |
||
36 | true |
||
37 | ); |
||
38 | $this->dom->addChild( |
||
39 | $ideEvento, |
||
40 | "verProc", |
||
41 | $this->verProc, |
||
42 | true |
||
43 | ); |
||
44 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
45 | |||
46 | //trabalhador (obrigatório) |
||
47 | $trabalhador = $this->dom->createElement("trabalhador"); |
||
48 | $this->dom->addChild( |
||
49 | $trabalhador, |
||
50 | "cpfTrab", |
||
51 | $this->std->cpftrab, |
||
52 | true |
||
53 | ); |
||
54 | $this->dom->addChild( |
||
55 | $trabalhador, |
||
56 | "nisTrab", |
||
57 | $this->std->nistrab, |
||
58 | true |
||
59 | ); |
||
60 | $this->dom->addChild( |
||
61 | $trabalhador, |
||
62 | "nmTrab", |
||
63 | $this->std->nmtrab, |
||
64 | true |
||
65 | ); |
||
66 | $this->dom->addChild( |
||
67 | $trabalhador, |
||
68 | "sexo", |
||
69 | $this->std->sexo, |
||
70 | true |
||
71 | ); |
||
72 | $this->dom->addChild( |
||
73 | $trabalhador, |
||
74 | "racaCor", |
||
75 | $this->std->racacor, |
||
76 | true |
||
77 | ); |
||
78 | $this->dom->addChild( |
||
79 | $trabalhador, |
||
80 | "estCiv", |
||
81 | ! empty($this->std->estciv) ? $this->std->estciv : null, |
||
82 | false |
||
83 | ); |
||
84 | $this->dom->addChild( |
||
85 | $trabalhador, |
||
86 | "grauInstr", |
||
87 | $this->std->grauinstr, |
||
88 | true |
||
89 | ); |
||
90 | $this->dom->addChild( |
||
91 | $trabalhador, |
||
92 | "indPriEmpr", |
||
93 | $this->std->indpriempr, |
||
94 | true |
||
95 | ); |
||
96 | $this->dom->addChild( |
||
97 | $trabalhador, |
||
98 | "nmSoc", |
||
99 | ! empty($this->std->nmsoc) ? $this->std->nmsoc : null, |
||
100 | false |
||
101 | ); |
||
102 | |||
103 | //nascimento (obrigatorio) |
||
104 | $nascimento = $this->dom->createElement("nascimento"); |
||
105 | $this->dom->addChild( |
||
106 | $nascimento, |
||
107 | "dtNascto", |
||
108 | $this->std->dtnascto, |
||
109 | true |
||
110 | ); |
||
111 | $this->dom->addChild( |
||
112 | $nascimento, |
||
113 | "codMunic", |
||
114 | ! empty($this->std->codmunic) ? $this->std->codmunic : null, |
||
115 | false |
||
116 | ); |
||
117 | $this->dom->addChild( |
||
118 | $nascimento, |
||
119 | "uf", |
||
120 | ! empty($this->std->uf) ? $this->std->uf : null, |
||
121 | false |
||
122 | ); |
||
123 | $this->dom->addChild( |
||
124 | $nascimento, |
||
125 | "paisNascto", |
||
126 | $this->std->paisnascto, |
||
127 | true |
||
128 | ); |
||
129 | $this->dom->addChild( |
||
130 | $nascimento, |
||
131 | "paisNac", |
||
132 | $this->std->paisnac, |
||
133 | true |
||
134 | ); |
||
135 | $this->dom->addChild( |
||
136 | $nascimento, |
||
137 | "nmMae", |
||
138 | ! empty($this->std->nmmae) ? $this->std->nmmae : null, |
||
139 | false |
||
140 | ); |
||
141 | $this->dom->addChild( |
||
142 | $nascimento, |
||
143 | "nmPai", |
||
144 | ! empty($this->std->nmpai) ? $this->std->nmpai : null, |
||
145 | false |
||
146 | ); |
||
147 | $trabalhador->appendChild($nascimento); |
||
148 | |||
149 | // documentos (obrig) |
||
150 | $documentos = $this->dom->createElement("documentos"); |
||
151 | //CTPS (Opc) |
||
152 | if (isset($this->std->ctps)) { |
||
153 | $doc = $this->std->ctps; |
||
154 | $ctps = $this->dom->createElement("CTPS"); |
||
155 | $this->dom->addChild( |
||
156 | $ctps, |
||
157 | "nrCtps", |
||
158 | $doc->nrctps, |
||
159 | true |
||
160 | ); |
||
161 | $this->dom->addChild( |
||
162 | $ctps, |
||
163 | "serieCtps", |
||
164 | $doc->seriectps, |
||
165 | true |
||
166 | ); |
||
167 | $this->dom->addChild( |
||
168 | $ctps, |
||
169 | "ufCtps", |
||
170 | $doc->ufctps, |
||
171 | true |
||
172 | ); |
||
173 | $documentos->appendChild($ctps); |
||
174 | } |
||
175 | //RIC (Opc) |
||
176 | if (isset($this->std->ric)) { |
||
177 | $doc = $this->std->ric; |
||
178 | $ric = $this->dom->createElement("RIC"); |
||
179 | $this->dom->addChild( |
||
180 | $ric, |
||
181 | "nrRic", |
||
182 | $doc->nrric, |
||
183 | true |
||
184 | ); |
||
185 | $this->dom->addChild( |
||
186 | $ric, |
||
187 | "orgaoEmissor", |
||
188 | $doc->orgaoemissor, |
||
189 | true |
||
190 | ); |
||
191 | $this->dom->addChild( |
||
192 | $ric, |
||
193 | "dtExped", |
||
194 | ! empty($doc->dtexped) ? $doc->dtexped : null, |
||
195 | false |
||
196 | ); |
||
197 | $documentos->appendChild($ric); |
||
198 | } |
||
199 | //RG |
||
200 | if (isset($this->std->rg)) { |
||
201 | $doc = $this->std->rg; |
||
202 | $rg = $this->dom->createElement("RG"); |
||
203 | $this->dom->addChild( |
||
204 | $rg, |
||
205 | "nrRg", |
||
206 | $doc->nrrg, |
||
207 | true |
||
208 | ); |
||
209 | $this->dom->addChild( |
||
210 | $rg, |
||
211 | "orgaoEmissor", |
||
212 | $doc->orgaoemissor, |
||
213 | true |
||
214 | ); |
||
215 | $this->dom->addChild( |
||
216 | $rg, |
||
217 | "dtExped", |
||
218 | ! empty($doc->dtexped) ? $doc->dtexped : null, |
||
219 | false |
||
220 | ); |
||
221 | $documentos->appendChild($rg); |
||
222 | } |
||
223 | //RNE (Opc) |
||
224 | if (isset($this->std->rne)) { |
||
225 | $doc = $this->std->rne; |
||
226 | $rne = $this->dom->createElement("RNE"); |
||
227 | $this->dom->addChild( |
||
228 | $rne, |
||
229 | "nrRne", |
||
230 | $doc->nrrne, |
||
231 | true |
||
232 | ); |
||
233 | $this->dom->addChild( |
||
234 | $rne, |
||
235 | "orgaoEmissor", |
||
236 | $doc->orgaoemissor, |
||
237 | true |
||
238 | ); |
||
239 | $this->dom->addChild( |
||
240 | $rne, |
||
241 | "dtExped", |
||
242 | ! empty($doc->dtexped) ? $doc->dtexped : null, |
||
243 | false |
||
244 | ); |
||
245 | $this->dom->addChild( |
||
246 | $rne, |
||
247 | "dtValid", |
||
248 | ! empty($doc->dtvalid) ? $doc->dtvalid : null, |
||
249 | false |
||
250 | ); |
||
251 | $documentos->appendChild($rne); |
||
252 | } |
||
253 | //OC (Opc) |
||
254 | if (isset($this->std->oc)) { |
||
255 | $doc = $this->std->oc; |
||
256 | $oc = $this->dom->createElement("OC"); |
||
257 | $this->dom->addChild( |
||
258 | $oc, |
||
259 | "nrOc", |
||
260 | $doc->nroc, |
||
261 | true |
||
262 | ); |
||
263 | $this->dom->addChild( |
||
264 | $oc, |
||
265 | "orgaoEmissor", |
||
266 | $doc->orgaoemissor, |
||
267 | true |
||
268 | ); |
||
269 | $this->dom->addChild( |
||
270 | $oc, |
||
271 | "dtExped", |
||
272 | ! empty($doc->dtexped) ? $doc->dtexped : null, |
||
273 | false |
||
274 | ); |
||
275 | $this->dom->addChild( |
||
276 | $oc, |
||
277 | "dtValid", |
||
278 | ! empty($doc->dtvalid) ? $doc->dtvalid : null, |
||
279 | false |
||
280 | ); |
||
281 | $documentos->appendChild($oc); |
||
282 | } |
||
283 | //CNH (Ops) |
||
284 | if (isset($this->std->cnh)) { |
||
285 | $doc = $this->std->cnh; |
||
286 | $cnh = $this->dom->createElement("CNH"); |
||
287 | $this->dom->addChild( |
||
288 | $cnh, |
||
289 | "nrRegCnh", |
||
290 | $doc->nrregcnh, |
||
291 | true |
||
292 | ); |
||
293 | $this->dom->addChild( |
||
294 | $cnh, |
||
295 | "dtExped", |
||
296 | ! empty($doc->dtexped) ? $doc->dtexped : null, |
||
297 | false |
||
298 | ); |
||
299 | $this->dom->addChild( |
||
300 | $cnh, |
||
301 | "ufCnh", |
||
302 | $doc->ufcnh, |
||
303 | true |
||
304 | ); |
||
305 | $this->dom->addChild( |
||
306 | $cnh, |
||
307 | "dtValid", |
||
308 | $doc->dtvalid, |
||
309 | true |
||
310 | ); |
||
311 | $this->dom->addChild( |
||
312 | $cnh, |
||
313 | "dtPriHab", |
||
314 | ! empty($doc->dtprihab) ? $doc->dtprihab : null, |
||
315 | false |
||
316 | ); |
||
317 | $this->dom->addChild( |
||
318 | $cnh, |
||
319 | "categoriaCnh", |
||
320 | $doc->categoriacnh, |
||
321 | true |
||
322 | ); |
||
323 | $documentos->appendChild($cnh); |
||
324 | } |
||
325 | $trabalhador->appendChild($documentos); |
||
326 | |||
327 | //Endereço (obrigatorio) |
||
328 | $endereco = $this->dom->createElement("endereco"); |
||
329 | if (isset($this->std->endereco->brasil)) { |
||
330 | $end = $this->std->endereco->brasil; |
||
331 | $brasil = $this->dom->createElement("brasil"); |
||
332 | $this->dom->addChild( |
||
333 | $brasil, |
||
334 | "tpLograd", |
||
335 | $end->tplograd, |
||
336 | true |
||
337 | ); |
||
338 | $this->dom->addChild( |
||
339 | $brasil, |
||
340 | "dscLograd", |
||
341 | $end->dsclograd, |
||
342 | true |
||
343 | ); |
||
344 | $this->dom->addChild( |
||
345 | $brasil, |
||
346 | "nrLograd", |
||
347 | $end->nrlograd, |
||
348 | true |
||
349 | ); |
||
350 | $this->dom->addChild( |
||
351 | $brasil, |
||
352 | "complemento", |
||
353 | ! empty($end->complemento) ? $end->complemento : null, |
||
354 | false |
||
355 | ); |
||
356 | $this->dom->addChild( |
||
357 | $brasil, |
||
358 | "bairro", |
||
359 | ! empty($end->bairro) ? $end->bairro : null, |
||
360 | true |
||
361 | ); |
||
362 | $this->dom->addChild( |
||
363 | $brasil, |
||
364 | "cep", |
||
365 | $end->cep, |
||
366 | true |
||
367 | ); |
||
368 | $this->dom->addChild( |
||
369 | $brasil, |
||
370 | "codMunic", |
||
371 | $end->codmunic, |
||
372 | true |
||
373 | ); |
||
374 | $this->dom->addChild( |
||
375 | $brasil, |
||
376 | "uf", |
||
377 | $end->uf, |
||
378 | true |
||
379 | ); |
||
380 | $endereco->appendChild($brasil); |
||
381 | } |
||
382 | if (isset($this->std->endereco->exterior) && !isset($this->std->endereco->brasil)) { |
||
383 | $end = $this->std->endereco->exterior; |
||
384 | $exterior = $this->dom->createElement("exterior"); |
||
385 | $this->dom->addChild( |
||
386 | $exterior, |
||
387 | "paisResid", |
||
388 | $end->paisresid, |
||
389 | true |
||
390 | ); |
||
391 | $this->dom->addChild( |
||
392 | $exterior, |
||
393 | "dscLograd", |
||
394 | $end->dsclograd, |
||
395 | true |
||
396 | ); |
||
397 | $this->dom->addChild( |
||
398 | $exterior, |
||
399 | "nrLograd", |
||
400 | $end->nrlograd, |
||
401 | true |
||
402 | ); |
||
403 | $this->dom->addChild( |
||
404 | $exterior, |
||
405 | "complemento", |
||
406 | ! empty($end->complemento) ? $end->complemento : null, |
||
407 | false |
||
408 | ); |
||
409 | $this->dom->addChild( |
||
410 | $exterior, |
||
411 | "bairro", |
||
412 | ! empty($end->bairro) ? $end->bairro : null, |
||
413 | false |
||
414 | ); |
||
415 | $this->dom->addChild( |
||
416 | $exterior, |
||
417 | "nmCid", |
||
418 | $end->nmcid, |
||
419 | true |
||
420 | ); |
||
421 | $this->dom->addChild( |
||
422 | $exterior, |
||
423 | "codPostal", |
||
424 | ! empty($end->codpostal) ? $end->codpostal : null, |
||
425 | false |
||
426 | ); |
||
427 | $endereco->appendChild($exterior); |
||
428 | } |
||
429 | $trabalhador->appendChild($endereco); |
||
430 | |||
431 | if (isset($this->std->trabestrangeiro)) { |
||
432 | $ex = $this->std->trabestrangeiro; |
||
433 | $trabEstrangeiro = $this->dom->createElement("trabEstrangeiro"); |
||
434 | $this->dom->addChild( |
||
435 | $trabEstrangeiro, |
||
436 | "dtChegada", |
||
437 | $ex->dtchegada, |
||
438 | true |
||
439 | ); |
||
440 | $this->dom->addChild( |
||
441 | $trabEstrangeiro, |
||
442 | "classTrabEstrang", |
||
443 | $ex->classtrabestrang, |
||
444 | true |
||
445 | ); |
||
446 | $this->dom->addChild( |
||
447 | $trabEstrangeiro, |
||
448 | "casadoBr", |
||
449 | $ex->casadobr, |
||
450 | true |
||
451 | ); |
||
452 | $this->dom->addChild( |
||
453 | $trabEstrangeiro, |
||
454 | "filhosBr", |
||
455 | $ex->filhosbr, |
||
456 | true |
||
457 | ); |
||
458 | $trabalhador->appendChild($trabEstrangeiro); |
||
459 | } |
||
460 | |||
461 | //deficiencia (opcional) |
||
462 | if (isset($this->std->infodeficiencia)) { |
||
463 | $def = $this->std->infodeficiencia; |
||
464 | $deficiencia = $this->dom->createElement("infoDeficiencia"); |
||
465 | $this->dom->addChild( |
||
466 | $deficiencia, |
||
467 | "defFisica", |
||
468 | $def->deffisica, |
||
469 | true |
||
470 | ); |
||
471 | $this->dom->addChild( |
||
472 | $deficiencia, |
||
473 | "defVisual", |
||
474 | $def->defvisual, |
||
475 | true |
||
476 | ); |
||
477 | $this->dom->addChild( |
||
478 | $deficiencia, |
||
479 | "defAuditiva", |
||
480 | $def->defauditiva, |
||
481 | true |
||
482 | ); |
||
483 | $this->dom->addChild( |
||
484 | $deficiencia, |
||
485 | "defMental", |
||
486 | $def->defmental, |
||
487 | true |
||
488 | ); |
||
489 | $this->dom->addChild( |
||
490 | $deficiencia, |
||
491 | "defIntelectual", |
||
492 | $def->defintelectual, |
||
493 | true |
||
494 | ); |
||
495 | $this->dom->addChild( |
||
496 | $deficiencia, |
||
497 | "reabReadap", |
||
498 | $def->reabreadap, |
||
499 | true |
||
500 | ); |
||
501 | $this->dom->addChild( |
||
502 | $deficiencia, |
||
503 | "infoCota", |
||
504 | $def->infocota, |
||
505 | true |
||
506 | ); |
||
507 | $this->dom->addChild( |
||
508 | $deficiencia, |
||
509 | "observacao", |
||
510 | ! empty($def->observacao) ? $def->observacao : null, |
||
511 | false |
||
512 | ); |
||
513 | $trabalhador->appendChild($deficiencia); |
||
514 | } |
||
515 | |||
516 | //dependentes (opcional) (ARRAY) |
||
517 | if (isset($this->std->dependente)) { |
||
518 | foreach ($this->std->dependente as $dep) { |
||
519 | $dependente = $this->dom->createElement("dependente"); |
||
520 | $this->dom->addChild( |
||
521 | $dependente, |
||
522 | "tpDep", |
||
523 | $dep->tpdep, |
||
524 | true |
||
525 | ); |
||
526 | $this->dom->addChild( |
||
527 | $dependente, |
||
528 | "nmDep", |
||
529 | $dep->nmdep, |
||
530 | true |
||
531 | ); |
||
532 | $this->dom->addChild( |
||
533 | $dependente, |
||
534 | "dtNascto", |
||
535 | $dep->dtnascto, |
||
536 | true |
||
537 | ); |
||
538 | $this->dom->addChild( |
||
539 | $dependente, |
||
540 | "cpfDep", |
||
541 | ! empty($dep->cpfdep) ? $dep->cpfdep : null, |
||
542 | false |
||
543 | ); |
||
544 | $this->dom->addChild( |
||
545 | $dependente, |
||
546 | "depIRRF", |
||
547 | $dep->depirrf, |
||
548 | true |
||
549 | ); |
||
550 | $this->dom->addChild( |
||
551 | $dependente, |
||
552 | "depSF", |
||
553 | $dep->depsf, |
||
554 | true |
||
555 | ); |
||
556 | $this->dom->addChild( |
||
557 | $dependente, |
||
558 | "incTrab", |
||
559 | $dep->inctrab, |
||
560 | true |
||
561 | ); |
||
562 | $trabalhador->appendChild($dependente); |
||
563 | } |
||
564 | } |
||
565 | |||
566 | //aposentadoria (opcional) |
||
567 | if (isset($this->std->aposentadoria)) { |
||
568 | $aposentadoria = $this->dom->createElement("aposentadoria"); |
||
569 | $this->dom->addChild( |
||
570 | $aposentadoria, |
||
571 | "trabAposent", |
||
572 | $this->std->aposentadoria->trabaposent, |
||
573 | true |
||
574 | ); |
||
575 | $trabalhador->appendChild($aposentadoria); |
||
576 | } |
||
577 | |||
578 | //contato (opcional) |
||
579 | if (isset($this->std->contato)) { |
||
580 | $doc = $this->std->contato; |
||
581 | $contato = $this->dom->createElement("contato"); |
||
582 | $this->dom->addChild( |
||
583 | $contato, |
||
584 | "fonePrinc", |
||
585 | ! empty($doc->foneprinc) ? $doc->foneprinc : null, |
||
586 | false |
||
587 | ); |
||
588 | $this->dom->addChild( |
||
589 | $contato, |
||
590 | "foneAlternat", |
||
591 | ! empty($doc->fonealternat) ? $doc->fonealternat : null, |
||
592 | false |
||
593 | ); |
||
594 | $this->dom->addChild( |
||
595 | $contato, |
||
596 | "emailPrinc", |
||
597 | ! empty($doc->emailprinc) ? $doc->emailprinc : null, |
||
598 | false |
||
599 | ); |
||
600 | $this->dom->addChild( |
||
601 | $contato, |
||
602 | "emailAlternat", |
||
603 | ! empty($doc->emailalternat) ? $doc->emailalternat : null, |
||
604 | false |
||
605 | ); |
||
606 | $trabalhador->appendChild($contato); |
||
607 | } |
||
608 | //encerra trabalhador |
||
609 | $this->node->appendChild($trabalhador); |
||
610 | |||
611 | |||
612 | //vinculo (obrigatorio) |
||
613 | $vinculo = $this->dom->createElement("vinculo"); |
||
614 | $vin = $this->std->vinculo; |
||
615 | $this->dom->addChild( |
||
616 | $vinculo, |
||
617 | "matricula", |
||
618 | $vin->matricula, |
||
619 | true |
||
620 | ); |
||
621 | $this->dom->addChild( |
||
622 | $vinculo, |
||
623 | "tpRegTrab", |
||
624 | $vin->tpregtrab, |
||
625 | true |
||
626 | ); |
||
627 | $this->dom->addChild( |
||
628 | $vinculo, |
||
629 | "tpRegPrev", |
||
630 | $vin->tpregprev, |
||
631 | true |
||
632 | ); |
||
633 | $this->dom->addChild( |
||
634 | $vinculo, |
||
635 | "nrRecInfPrelim", |
||
636 | ! empty($vin->nrrecinfprelim) ? $vin->nrrecinfprelim : null, |
||
637 | false |
||
638 | ); |
||
639 | $this->dom->addChild( |
||
640 | $vinculo, |
||
641 | "cadIni", |
||
642 | $vin->cadini, |
||
643 | true |
||
644 | ); |
||
645 | |||
646 | $infoRegimeTrab = $this->dom->createElement("infoRegimeTrab"); |
||
647 | if (isset($vin->infoceletista)) { |
||
648 | $std = $vin->infoceletista; |
||
649 | $celetista = $this->dom->createElement("infoCeletista"); |
||
650 | $this->dom->addChild( |
||
651 | $celetista, |
||
652 | "dtAdm", |
||
653 | $std->dtadm, |
||
654 | true |
||
655 | ); |
||
656 | $this->dom->addChild( |
||
657 | $celetista, |
||
658 | "tpAdmissao", |
||
659 | $std->tpadmissao, |
||
660 | true |
||
661 | ); |
||
662 | $this->dom->addChild( |
||
663 | $celetista, |
||
664 | "indAdmissao", |
||
665 | $std->indadmissao, |
||
666 | true |
||
667 | ); |
||
668 | $this->dom->addChild( |
||
669 | $celetista, |
||
670 | "tpRegJor", |
||
671 | $std->tpregjor, |
||
672 | true |
||
673 | ); |
||
674 | $this->dom->addChild( |
||
675 | $celetista, |
||
676 | "natAtividade", |
||
677 | $std->natatividade, |
||
678 | true |
||
679 | ); |
||
680 | $this->dom->addChild( |
||
681 | $celetista, |
||
682 | "dtBase", |
||
683 | ! empty($std->dtbase) ? $std->dtbase : null, |
||
684 | false |
||
685 | ); |
||
686 | $this->dom->addChild( |
||
687 | $celetista, |
||
688 | "cnpjSindCategProf", |
||
689 | $std->cnpjsindcategprof, |
||
690 | true |
||
691 | ); |
||
692 | //FGTS (obrigatorio) |
||
693 | $fgts = $this->dom->createElement("FGTS"); |
||
694 | $this->dom->addChild( |
||
695 | $fgts, |
||
696 | "opcFGTS", |
||
697 | $std->opcfgts, |
||
698 | true |
||
699 | ); |
||
700 | $this->dom->addChild( |
||
701 | $fgts, |
||
702 | "dtOpcFGTS", |
||
703 | ! empty($std->dtopcfgts) ? $std->dtopcfgts : null, |
||
704 | false |
||
705 | ); |
||
706 | $celetista->appendChild($fgts); |
||
707 | |||
708 | if (isset($std->trabtemporario)) { |
||
709 | $trabTemporario = $this->dom->createElement("trabTemporario"); |
||
710 | $this->dom->addChild( |
||
711 | $trabTemporario, |
||
712 | "hipLeg", |
||
713 | $std->trabtemporario->hipleg, |
||
714 | true |
||
715 | ); |
||
716 | $this->dom->addChild( |
||
717 | $trabTemporario, |
||
718 | "justContr", |
||
719 | $std->trabtemporario->justcontr, |
||
720 | true |
||
721 | ); |
||
722 | $this->dom->addChild( |
||
723 | $trabTemporario, |
||
724 | "tpInclContr", |
||
725 | $std->trabtemporario->tpinclcontr, |
||
726 | true |
||
727 | ); |
||
728 | $ideTomadorServ = $this->dom->createElement("ideTomadorServ"); |
||
729 | $this->dom->addChild( |
||
730 | $ideTomadorServ, |
||
731 | "tpInsc", |
||
732 | $std->trabtemporario->idetomadorserv->tpinsc, |
||
733 | true |
||
734 | ); |
||
735 | $this->dom->addChild( |
||
736 | $ideTomadorServ, |
||
737 | "nrInsc", |
||
738 | $std->trabtemporario->idetomadorserv->nrinsc, |
||
739 | true |
||
740 | ); |
||
741 | |||
742 | if (isset($std->trabtemporario->idetomadorserv->ideestabvinc)) { |
||
743 | $ts = $std->trabtemporario->idetomadorserv->ideestabvinc; |
||
744 | $ideEstabVinc = $this->dom->createElement("ideEstabVinc"); |
||
745 | $this->dom->addChild( |
||
746 | $ideEstabVinc, |
||
747 | "tpInsc", |
||
748 | $ts->tpinsc, |
||
749 | true |
||
750 | ); |
||
751 | $this->dom->addChild( |
||
752 | $ideEstabVinc, |
||
753 | "nrInsc", |
||
754 | $ts->nrinsc, |
||
755 | true |
||
756 | ); |
||
757 | $ideTomadorServ->appendChild($ideEstabVinc); |
||
758 | } |
||
759 | $trabTemporario->appendChild($ideTomadorServ); |
||
760 | |||
761 | //substituido (opcional) ARRAY |
||
762 | if (isset($std->trabtemporario->idetrabsubstituido)) { |
||
763 | foreach ($std->trabtemporario->idetrabsubstituido as $subs) { |
||
764 | $ideTrabSubstituido = $this->dom->createElement("ideTrabSubstituido"); |
||
765 | $this->dom->addChild( |
||
766 | $ideTrabSubstituido, |
||
767 | "cpfTrabSubst", |
||
768 | $subs->cpftrabsubst, |
||
769 | true |
||
770 | ); |
||
771 | $trabTemporario->appendChild($ideTrabSubstituido); |
||
772 | } |
||
773 | } |
||
774 | $celetista->appendChild($trabTemporario); |
||
775 | } |
||
776 | //aprendiz (opcional) |
||
777 | if (isset($std->aprend)) { |
||
778 | $aprendiz = $this->dom->createElement("aprend"); |
||
779 | $this->dom->addChild( |
||
780 | $aprendiz, |
||
781 | "tpInsc", |
||
782 | $std->aprend->tpinsc, |
||
783 | true |
||
784 | ); |
||
785 | $this->dom->addChild( |
||
786 | $aprendiz, |
||
787 | "nrInsc", |
||
788 | $std->aprend->nrinsc, |
||
789 | true |
||
790 | ); |
||
791 | $celetista->appendChild($aprendiz); |
||
792 | } |
||
793 | $infoRegimeTrab->appendChild($celetista); |
||
794 | } elseif (isset($vin->infoestatutario)) { |
||
795 | $std = $vin->infoestatutario; |
||
796 | $estatutario = $this->dom->createElement("infoEstatutario"); |
||
797 | $this->dom->addChild( |
||
798 | $estatutario, |
||
799 | "indProvim", |
||
800 | $std->indprovim, |
||
801 | true |
||
802 | ); |
||
803 | $this->dom->addChild( |
||
804 | $estatutario, |
||
805 | "tpProv", |
||
806 | $std->tpprov, |
||
807 | true |
||
808 | ); |
||
809 | $this->dom->addChild( |
||
810 | $estatutario, |
||
811 | "dtNomeacao", |
||
812 | $std->dtnomeacao, |
||
813 | true |
||
814 | ); |
||
815 | $this->dom->addChild( |
||
816 | $estatutario, |
||
817 | "dtPosse", |
||
818 | $std->dtposse, |
||
819 | true |
||
820 | ); |
||
821 | $this->dom->addChild( |
||
822 | $estatutario, |
||
823 | "dtExercicio", |
||
824 | $std->dtexercicio, |
||
825 | true |
||
826 | ); |
||
827 | $this->dom->addChild( |
||
828 | $estatutario, |
||
829 | "tpPlanRP", |
||
830 | ! empty($std->tpplanrp) ? $std->tpplanrp : null, |
||
831 | false |
||
832 | ); |
||
833 | //infoDecJud (opcional) |
||
834 | if (isset($std->infodecjud)) { |
||
835 | $infoDecJud = $this->dom->createElement("infoDecJud"); |
||
836 | $this->dom->addChild( |
||
837 | $infoDecJud, |
||
838 | "nrProcJud", |
||
839 | $std->infodecjud->nrprocjud, |
||
840 | true |
||
841 | ); |
||
842 | $estatutario->appendChild($infoDecJud); |
||
843 | } |
||
844 | $infoRegimeTrab->appendChild($estatutario); |
||
845 | } |
||
846 | $vinculo->appendChild($infoRegimeTrab); |
||
847 | |||
848 | //infoContrato (obrigatorio) |
||
849 | $contrato = $this->dom->createElement("infoContrato"); |
||
850 | $std = $vin->infocontrato; |
||
851 | $this->dom->addChild( |
||
852 | $contrato, |
||
853 | "codCargo", |
||
854 | ! empty($std->codcargo) ? $std->codcargo : null, |
||
855 | false |
||
856 | ); |
||
857 | $this->dom->addChild( |
||
858 | $contrato, |
||
859 | "codFuncao", |
||
860 | ! empty($std->codfuncao) ? $std->codfuncao : null, |
||
861 | false |
||
862 | ); |
||
863 | $this->dom->addChild( |
||
864 | $contrato, |
||
865 | "codCateg", |
||
866 | $std->codcateg, |
||
867 | true |
||
868 | ); |
||
869 | $this->dom->addChild( |
||
870 | $contrato, |
||
871 | "codCarreira", |
||
872 | ! empty($std->codcarreira) ? $std->codcarreira : null, |
||
873 | false |
||
874 | ); |
||
875 | $this->dom->addChild( |
||
876 | $contrato, |
||
877 | "dtIngrCarr", |
||
878 | ! empty($std->dtingrcarr) ? $std->dtingrcarr : null, |
||
879 | false |
||
880 | ); |
||
881 | //remuneracao (obrigatorio) |
||
882 | $remuneracao = $this->dom->createElement("remuneracao"); |
||
883 | $this->dom->addChild( |
||
884 | $remuneracao, |
||
885 | "vrSalFx", |
||
886 | $std->vrsalfx, |
||
887 | true |
||
888 | ); |
||
889 | $this->dom->addChild( |
||
890 | $remuneracao, |
||
891 | "undSalFixo", |
||
892 | $std->undsalfixo, |
||
893 | true |
||
894 | ); |
||
895 | $this->dom->addChild( |
||
896 | $remuneracao, |
||
897 | "dscSalVar", |
||
898 | ! empty($std->dscsalvar) ? $std->dscsalvar : null, |
||
899 | false |
||
900 | ); |
||
901 | $contrato->appendChild($remuneracao); |
||
902 | //duracao (obrigatorio) |
||
903 | $duracao = $this->dom->createElement("duracao"); |
||
904 | $this->dom->addChild( |
||
905 | $duracao, |
||
906 | "tpContr", |
||
907 | $std->tpcontr, |
||
908 | true |
||
909 | ); |
||
910 | $this->dom->addChild( |
||
911 | $duracao, |
||
912 | "dtTerm", |
||
913 | ! empty($std->dtterm) ? $std->dtterm : null, |
||
914 | false |
||
915 | ); |
||
916 | $this->dom->addChild( |
||
917 | $duracao, |
||
918 | "clauAssec", |
||
919 | ! empty($std->clauassec) ? $std->clauassec : null, |
||
920 | false |
||
921 | ); |
||
922 | $this->dom->addChild( |
||
923 | $duracao, |
||
924 | "objDet", |
||
925 | ! empty($std->objdet) ? $std->objdet : null, |
||
926 | false |
||
927 | ); |
||
928 | $contrato->appendChild($duracao); |
||
929 | //localTrabalho (obrigatorio) |
||
930 | $localTrabalho = $this->dom->createElement("localTrabalho"); |
||
931 | //localTrabGeral (opcional) |
||
932 | if (isset($std->localtrabgeral)) { |
||
933 | $localgeral = $this->dom->createElement("localTrabGeral"); |
||
934 | $this->dom->addChild( |
||
935 | $localgeral, |
||
936 | "tpInsc", |
||
937 | $std->localtrabgeral->tpinsc, |
||
938 | true |
||
939 | ); |
||
940 | $this->dom->addChild( |
||
941 | $localgeral, |
||
942 | "nrInsc", |
||
943 | $std->localtrabgeral->nrinsc, |
||
944 | true |
||
945 | ); |
||
946 | $this->dom->addChild( |
||
947 | $localgeral, |
||
948 | "descComp", |
||
949 | ! empty($std->localtrabgeral->desccomp) ? $std->localtrabgeral->desccomp : null, |
||
950 | false |
||
951 | ); |
||
952 | $localTrabalho->appendChild($localgeral); |
||
953 | } |
||
954 | //localTrabDom (opcional) |
||
955 | if (isset($std->localtrabdom)) { |
||
956 | $ld = $std->localtrabdom; |
||
957 | $localDomestico = $this->dom->createElement("localTrabDom"); |
||
958 | $this->dom->addChild( |
||
959 | $localDomestico, |
||
960 | "tpLograd", |
||
961 | $ld->tplograd, |
||
962 | true |
||
963 | ); |
||
964 | $this->dom->addChild( |
||
965 | $localDomestico, |
||
966 | "dscLograd", |
||
967 | $ld->dsclograd, |
||
968 | true |
||
969 | ); |
||
970 | $this->dom->addChild( |
||
971 | $localDomestico, |
||
972 | "nrLograd", |
||
973 | $ld->nrlograd, |
||
974 | true |
||
975 | ); |
||
976 | $this->dom->addChild( |
||
977 | $localDomestico, |
||
978 | "complemento", |
||
979 | ! empty($ld->complemento) ? $ld->complemento : null, |
||
980 | false |
||
981 | ); |
||
982 | $this->dom->addChild( |
||
983 | $localDomestico, |
||
984 | "bairro", |
||
985 | ! empty($ld->bairro) ? $ld->bairro : null, |
||
986 | false |
||
987 | ); |
||
988 | $this->dom->addChild( |
||
989 | $localDomestico, |
||
990 | "cep", |
||
991 | $ld->cep, |
||
992 | true |
||
993 | ); |
||
994 | $this->dom->addChild( |
||
995 | $localDomestico, |
||
996 | "codMunic", |
||
997 | $ld->codmunic, |
||
998 | true |
||
999 | ); |
||
1000 | $this->dom->addChild( |
||
1001 | $localDomestico, |
||
1002 | "uf", |
||
1003 | $ld->uf, |
||
1004 | true |
||
1005 | ); |
||
1006 | $localTrabalho->appendChild($localDomestico); |
||
1007 | } |
||
1008 | $contrato->appendChild($localTrabalho); |
||
1009 | |||
1010 | //horContratual (opcional) |
||
1011 | if (isset($std->horcontratual)) { |
||
1012 | $hc = $std->horcontratual; |
||
1013 | $horContratual = $this->dom->createElement("horContratual"); |
||
1014 | $this->dom->addChild( |
||
1015 | $horContratual, |
||
1016 | "qtdHrsSem", |
||
1017 | $hc->qtdhrssem, |
||
1018 | true |
||
1019 | ); |
||
1020 | $this->dom->addChild( |
||
1021 | $horContratual, |
||
1022 | "tpJornada", |
||
1023 | $hc->tpjornada, |
||
1024 | true |
||
1025 | ); |
||
1026 | $this->dom->addChild( |
||
1027 | $horContratual, |
||
1028 | "dscTpJorn", |
||
1029 | ! empty($hc->dsctpjorn) ? $hc->dsctpjorn : null, |
||
1030 | false |
||
1031 | ); |
||
1032 | $this->dom->addChild( |
||
1033 | $horContratual, |
||
1034 | "tmpParc", |
||
1035 | $hc->tmpparc, |
||
1036 | true |
||
1037 | ); |
||
1038 | //horario (opcional) ARRAY |
||
1039 | if (isset($hc->horario)) { |
||
1040 | foreach ($hc->horario as $hr) { |
||
1041 | $horario = $this->dom->createElement("horario"); |
||
1042 | $this->dom->addChild( |
||
1043 | $horario, |
||
1044 | "dia", |
||
1045 | $hr->dia, |
||
1046 | true |
||
1047 | ); |
||
1048 | $this->dom->addChild( |
||
1049 | $horario, |
||
1050 | "codHorContrat", |
||
1051 | $hr->codhorcontrat, |
||
1052 | true |
||
1053 | ); |
||
1054 | $horContratual->appendChild($horario); |
||
1055 | } |
||
1056 | } |
||
1057 | //encerra horContratual |
||
1058 | $contrato->appendChild($horContratual); |
||
1059 | } |
||
1060 | //filiacaoSindical (opcional) ARRAY |
||
1061 | if (isset($std->filiacaosindical)) { |
||
1062 | foreach ($std->filiacaosindical as $sind) { |
||
1063 | $filiacaoSindical = $this->dom->createElement("filiacaoSindical"); |
||
1064 | $this->dom->addChild( |
||
1065 | $filiacaoSindical, |
||
1066 | "cnpjSindTrab", |
||
1067 | $sind->cnpjsindtrab, |
||
1068 | true |
||
1069 | ); |
||
1070 | $contrato->appendChild($filiacaoSindical); |
||
1071 | } |
||
1072 | } |
||
1073 | //alvaraJudicial (opcional) |
||
1074 | if (isset($std->alvarajudicial)) { |
||
1075 | $alvaraJudicial = $this->dom->createElement("alvaraJudicial"); |
||
1076 | $this->dom->addChild( |
||
1077 | $alvaraJudicial, |
||
1078 | "nrProcJud", |
||
1079 | $std->alvarajudicial->nrprocjud, |
||
1080 | true |
||
1081 | ); |
||
1082 | $contrato->appendChild($alvaraJudicial); |
||
1083 | } |
||
1084 | //observacoes (opcional) |
||
1085 | if (isset($std->observacoes)) { |
||
1086 | foreach ($std->observacoes as $obs) { |
||
1087 | $observacoes = $this->dom->createElement("observacoes"); |
||
1088 | $this->dom->addChild( |
||
1089 | $observacoes, |
||
1090 | "observacao", |
||
1091 | $obs->observacao, |
||
1092 | true |
||
1093 | ); |
||
1094 | $contrato->appendChild($observacoes); |
||
1095 | } |
||
1096 | } |
||
1097 | $vinculo->appendChild($contrato); |
||
1098 | |||
1099 | //sucessaoVinc (opcional) |
||
1100 | if (isset($vin->sucessaovinc)) { |
||
1101 | $std = $vin->sucessaovinc; |
||
1102 | $sucessaoVinc = $this->dom->createElement("sucessaoVinc"); |
||
1103 | $this->dom->addChild( |
||
1104 | $sucessaoVinc, |
||
1105 | "tpInscAnt", |
||
1106 | !empty($std->tpinscant) ? $std->tpinscant : null, |
||
1107 | false |
||
1108 | ); |
||
1109 | $this->dom->addChild( |
||
1110 | $sucessaoVinc, |
||
1111 | "cnpjEmpregAnt", |
||
1112 | $std->cnpjempregant, |
||
1113 | true |
||
1114 | ); |
||
1115 | $this->dom->addChild( |
||
1116 | $sucessaoVinc, |
||
1117 | "matricAnt", |
||
1118 | ! empty($std->matricant) ? $std->matricant : null, |
||
1119 | false |
||
1120 | ); |
||
1121 | $this->dom->addChild( |
||
1122 | $sucessaoVinc, |
||
1123 | "dtTransf", |
||
1124 | $std->dttransf, |
||
1125 | true |
||
1126 | ); |
||
1127 | $this->dom->addChild( |
||
1128 | $sucessaoVinc, |
||
1129 | "observacao", |
||
1130 | ! empty($std->observacao) ? $std->observacao : null, |
||
1131 | false |
||
1132 | ); |
||
1133 | $vinculo->appendChild($sucessaoVinc); |
||
1134 | } |
||
1135 | //transfDom (opcional) |
||
1136 | if (isset($vin->transfdom)) { |
||
1137 | $std = $vin->transfdom; |
||
1138 | $transfDom = $this->dom->createElement("transfDom"); |
||
1139 | $this->dom->addChild( |
||
1140 | $transfDom, |
||
1141 | "cpfSubstituido", |
||
1142 | $std->cpfsubstituido, |
||
1143 | true |
||
1144 | ); |
||
1145 | $this->dom->addChild( |
||
1146 | $transfDom, |
||
1147 | "matricAnt", |
||
1148 | ! empty($std->matricant) ? $std->matricant : null, |
||
1149 | false |
||
1150 | ); |
||
1151 | $this->dom->addChild( |
||
1152 | $transfDom, |
||
1153 | "dtTransf", |
||
1154 | $std->dttransf, |
||
1155 | true |
||
1156 | ); |
||
1157 | $vinculo->appendChild($transfDom); |
||
1158 | } |
||
1159 | //afastamento (opcional) |
||
1160 | if (isset($this->std->vinculo->afastamento)) { |
||
1161 | $std = $this->std->vinculo->afastamento; |
||
1162 | $afastamento = $this->dom->createElement("afastamento"); |
||
1163 | $this->dom->addChild( |
||
1164 | $afastamento, |
||
1165 | "dtIniAfast", |
||
1166 | $std->dtiniafast, |
||
1167 | true |
||
1168 | ); |
||
1169 | $this->dom->addChild( |
||
1170 | $afastamento, |
||
1171 | "codMotAfast", |
||
1172 | $std->codmotafast, |
||
1173 | true |
||
1174 | ); |
||
1175 | $vinculo->appendChild($afastamento); |
||
1176 | } |
||
1177 | |||
1178 | //desligamento (opcional) |
||
1179 | if (isset($this->std->vinculo->desligamento)) { |
||
1180 | $std = $this->std->vinculo->desligamento; |
||
1181 | $desligamento = $this->dom->createElement("desligamento"); |
||
1182 | $this->dom->addChild( |
||
1183 | $desligamento, |
||
1184 | "dtDeslig", |
||
1185 | $std->dtdeslig, |
||
1186 | true |
||
1187 | ); |
||
1188 | $vinculo->appendChild($desligamento); |
||
1189 | } |
||
1190 | |||
1191 | //encerra vinculo |
||
1192 | $this->node->appendChild($vinculo); |
||
1193 | //finalização do xml |
||
1194 | $this->eSocial->appendChild($this->node); |
||
1195 | //$this->xml = $this->dom->saveXML($this->eSocial);; |
||
1196 | $this->sign(); |
||
1197 | } |
||
1198 | |||
1207 |
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: