| Conditions | 32 |
| Paths | 864 |
| Total Lines | 407 |
| 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 | $ideVinculo = $this->dom->createElement("ideVinculo"); |
||
| 47 | $this->dom->addChild( |
||
| 48 | $ideVinculo, |
||
| 49 | "cpfTrab", |
||
| 50 | $this->std->cpftrab, |
||
| 51 | true |
||
| 52 | ); |
||
| 53 | $this->dom->addChild( |
||
| 54 | $ideVinculo, |
||
| 55 | "nisTrab", |
||
| 56 | $this->std->nistrab, |
||
| 57 | true |
||
| 58 | ); |
||
| 59 | $this->dom->addChild( |
||
| 60 | $ideVinculo, |
||
| 61 | "matricula", |
||
| 62 | $this->std->matricula, |
||
| 63 | true |
||
| 64 | ); |
||
| 65 | $this->node->appendChild($ideVinculo); |
||
| 66 | |||
| 67 | $altContratual = $this->dom->createElement("altContratual"); |
||
| 68 | $this->dom->addChild( |
||
| 69 | $altContratual, |
||
| 70 | "dtAlteracao", |
||
| 71 | $this->std->dtalteracao, |
||
| 72 | true |
||
| 73 | ); |
||
| 74 | $this->dom->addChild( |
||
| 75 | $altContratual, |
||
| 76 | "dtEf", |
||
| 77 | !empty($this->std->dtef) ? $this->std->dtef : null, |
||
| 78 | false |
||
| 79 | ); |
||
| 80 | $this->dom->addChild( |
||
| 81 | $altContratual, |
||
| 82 | "dscAlt", |
||
| 83 | !empty($this->std->dscalt) ? $this->std->dscalt : null, |
||
| 84 | false |
||
| 85 | ); |
||
| 86 | |||
| 87 | $vinculo = $this->dom->createElement("vinculo"); |
||
| 88 | $this->dom->addChild( |
||
| 89 | $vinculo, |
||
| 90 | "tpRegPrev", |
||
| 91 | $this->std->tpregprev, |
||
| 92 | true |
||
| 93 | ); |
||
| 94 | $altContratual->appendChild($vinculo); |
||
| 95 | |||
| 96 | $infoRegimeTrab = $this->dom->createElement("infoRegimeTrab"); |
||
| 97 | if (!empty($this->std->infoceletista)) { |
||
| 98 | $ct = $this->std->infoceletista; |
||
| 99 | $infoCeletista = $this->dom->createElement("infoCeletista"); |
||
| 100 | $this->dom->addChild( |
||
| 101 | $infoCeletista, |
||
| 102 | "tpRegJor", |
||
| 103 | $ct->tpregjor, |
||
| 104 | true |
||
| 105 | ); |
||
| 106 | $this->dom->addChild( |
||
| 107 | $infoCeletista, |
||
| 108 | "natAtividade", |
||
| 109 | $ct->natatividade, |
||
| 110 | true |
||
| 111 | ); |
||
| 112 | $this->dom->addChild( |
||
| 113 | $infoCeletista, |
||
| 114 | "dtBase", |
||
| 115 | !empty($ct->dtbase) ? $ct->dtbase : null, |
||
| 116 | false |
||
| 117 | ); |
||
| 118 | $this->dom->addChild( |
||
| 119 | $infoCeletista, |
||
| 120 | "cnpjSindCategProf", |
||
| 121 | $ct->cnpjsindcategprof, |
||
| 122 | true |
||
| 123 | ); |
||
| 124 | if (!empty($ct->trabtemp)) { |
||
| 125 | $trabTemp = $this->dom->createElement("trabTemp"); |
||
| 126 | $this->dom->addChild( |
||
| 127 | $trabTemp, |
||
| 128 | "justProrr", |
||
| 129 | $ct->trabtemp->justprorr, |
||
| 130 | true |
||
| 131 | ); |
||
| 132 | $infoCeletista->appendChild($trabTemp); |
||
| 133 | } |
||
| 134 | if (!empty($ct->aprend)) { |
||
| 135 | $aprend = $this->dom->createElement("aprend"); |
||
| 136 | $this->dom->addChild( |
||
| 137 | $aprend, |
||
| 138 | "tpInsc", |
||
| 139 | $ct->aprend->tpinsc, |
||
| 140 | true |
||
| 141 | ); |
||
| 142 | $this->dom->addChild( |
||
| 143 | $aprend, |
||
| 144 | "nrInsc", |
||
| 145 | $ct->aprend->nrinsc, |
||
| 146 | true |
||
| 147 | ); |
||
| 148 | $infoCeletista->appendChild($aprend); |
||
| 149 | } |
||
| 150 | $infoRegimeTrab->appendChild($infoCeletista); |
||
| 151 | } elseif (!empty($this->std->infoestatutario)) { |
||
| 152 | $ct = $this->std->infoestatutario; |
||
| 153 | $infoEstatutario = $this->dom->createElement("infoEstatutario"); |
||
| 154 | $this->dom->addChild( |
||
| 155 | $infoEstatutario, |
||
| 156 | "tpPlanRP", |
||
| 157 | $ct->tpPlanRP, |
||
| 158 | true |
||
| 159 | ); |
||
| 160 | $infoRegimeTrab->appendChild($infoEstatutario); |
||
| 161 | } |
||
| 162 | $altContratual->appendChild($infoRegimeTrab); |
||
| 163 | |||
| 164 | $infoContrato = $this->dom->createElement("infoContrato"); |
||
| 165 | $ct = $this->std->infocontrato; |
||
| 166 | $this->dom->addChild( |
||
| 167 | $infoContrato, |
||
| 168 | "codCargo", |
||
| 169 | !empty($ct->codcargo) ? $ct->codcargo : null, |
||
| 170 | false |
||
| 171 | ); |
||
| 172 | $this->dom->addChild( |
||
| 173 | $infoContrato, |
||
| 174 | "codFuncao", |
||
| 175 | !empty($ct->codfuncao) ? $ct->codfuncao : null, |
||
| 176 | false |
||
| 177 | ); |
||
| 178 | $this->dom->addChild( |
||
| 179 | $infoContrato, |
||
| 180 | "codCateg", |
||
| 181 | $ct->codcateg, |
||
| 182 | true |
||
| 183 | ); |
||
| 184 | $this->dom->addChild( |
||
| 185 | $infoContrato, |
||
| 186 | "codCarreira", |
||
| 187 | !empty($ct->codcarreira) ? $ct->codcarreira : null, |
||
| 188 | false |
||
| 189 | ); |
||
| 190 | $this->dom->addChild( |
||
| 191 | $infoContrato, |
||
| 192 | "dtIngrCarr", |
||
| 193 | !empty($ct->dtingrcarr) ? $ct->dtingrcarr : null, |
||
| 194 | false |
||
| 195 | ); |
||
| 196 | $remuneracao = $this->dom->createElement("remuneracao"); |
||
| 197 | $this->dom->addChild( |
||
| 198 | $remuneracao, |
||
| 199 | "vrSalFx", |
||
| 200 | $ct->vrsalfx, |
||
| 201 | true |
||
| 202 | ); |
||
| 203 | $this->dom->addChild( |
||
| 204 | $remuneracao, |
||
| 205 | "undSalFixo", |
||
| 206 | $ct->undsalfixo, |
||
| 207 | true |
||
| 208 | ); |
||
| 209 | $this->dom->addChild( |
||
| 210 | $remuneracao, |
||
| 211 | "dscSalVar", |
||
| 212 | !empty($ct->dscsalvar) ? $ct->dscsalvar : null, |
||
| 213 | false |
||
| 214 | ); |
||
| 215 | $infoContrato->appendChild($remuneracao); |
||
| 216 | $duracao = $this->dom->createElement("duracao"); |
||
| 217 | $this->dom->addChild( |
||
| 218 | $duracao, |
||
| 219 | "tpContr", |
||
| 220 | $ct->tpcontr, |
||
| 221 | true |
||
| 222 | ); |
||
| 223 | $this->dom->addChild( |
||
| 224 | $duracao, |
||
| 225 | "dtTerm", |
||
| 226 | !empty($ct->dtterm) ? $ct->dtterm : null, |
||
| 227 | false |
||
| 228 | ); |
||
| 229 | $this->dom->addChild( |
||
| 230 | $duracao, |
||
| 231 | "objDet", |
||
| 232 | !empty($ct->objdet) ? $ct->objdet : null, |
||
| 233 | false |
||
| 234 | ); |
||
| 235 | $infoContrato->appendChild($duracao); |
||
| 236 | |||
| 237 | $localTrabalho = $this->dom->createElement("localTrabalho"); |
||
| 238 | if (!empty($this->std->localtrabgeral)) { |
||
| 239 | $tg = $this->std->localtrabgeral; |
||
| 240 | $localTrabGeral = $this->dom->createElement("localTrabGeral"); |
||
| 241 | $this->dom->addChild( |
||
| 242 | $localTrabGeral, |
||
| 243 | "tpInsc", |
||
| 244 | $tg->tpinsc, |
||
| 245 | true |
||
| 246 | ); |
||
| 247 | $this->dom->addChild( |
||
| 248 | $localTrabGeral, |
||
| 249 | "nrInsc", |
||
| 250 | $tg->nrinsc, |
||
| 251 | true |
||
| 252 | ); |
||
| 253 | $this->dom->addChild( |
||
| 254 | $localTrabGeral, |
||
| 255 | "descComp", |
||
| 256 | !empty($tg->desccomp) ? $tg->desccomp : null, |
||
| 257 | false |
||
| 258 | ); |
||
| 259 | $localTrabalho->appendChild($localTrabGeral); |
||
| 260 | } elseif (!empty($this->std->localtrabdom)) { |
||
| 261 | $tg = $this->std->localtrabdom; |
||
| 262 | $localTrabDom = $this->dom->createElement("localTrabDom"); |
||
| 263 | $this->dom->addChild( |
||
| 264 | $localTrabDom, |
||
| 265 | "tpLograd", |
||
| 266 | $tg->tplograd, |
||
| 267 | true |
||
| 268 | ); |
||
| 269 | $this->dom->addChild( |
||
| 270 | $localTrabDom, |
||
| 271 | "dscLograd", |
||
| 272 | $tg->dsclograd, |
||
| 273 | true |
||
| 274 | ); |
||
| 275 | $this->dom->addChild( |
||
| 276 | $localTrabDom, |
||
| 277 | "nrLograd", |
||
| 278 | $tg->nrlograd, |
||
| 279 | true |
||
| 280 | ); |
||
| 281 | $this->dom->addChild( |
||
| 282 | $localTrabDom, |
||
| 283 | "complemento", |
||
| 284 | !empty($tg->complemento) ? $tg->complemento : null, |
||
| 285 | false |
||
| 286 | ); |
||
| 287 | $this->dom->addChild( |
||
| 288 | $localTrabDom, |
||
| 289 | "bairro", |
||
| 290 | !empty($tg->bairro) ? $tg->bairro : null, |
||
| 291 | false |
||
| 292 | ); |
||
| 293 | $this->dom->addChild( |
||
| 294 | $localTrabDom, |
||
| 295 | "cep", |
||
| 296 | $tg->cep, |
||
| 297 | true |
||
| 298 | ); |
||
| 299 | $this->dom->addChild( |
||
| 300 | $localTrabDom, |
||
| 301 | "codMunic", |
||
| 302 | $tg->codmunic, |
||
| 303 | true |
||
| 304 | ); |
||
| 305 | $this->dom->addChild( |
||
| 306 | $localTrabDom, |
||
| 307 | "uf", |
||
| 308 | $tg->uf, |
||
| 309 | true |
||
| 310 | ); |
||
| 311 | $localTrabalho->appendChild($localTrabDom); |
||
| 312 | } |
||
| 313 | $infoContrato->appendChild($localTrabalho); |
||
| 314 | |||
| 315 | if (!empty($this->std->horcontratual)) { |
||
| 316 | $hc = $this->std->horcontratual; |
||
| 317 | $horContratual = $this->dom->createElement("horContratual"); |
||
| 318 | $this->dom->addChild( |
||
| 319 | $horContratual, |
||
| 320 | "qtdHrsSem", |
||
| 321 | !empty($hc->qtdhrssem) ? $hc->qtdhrssem : null, |
||
| 322 | false |
||
| 323 | ); |
||
| 324 | $this->dom->addChild( |
||
| 325 | $horContratual, |
||
| 326 | "tpJornada", |
||
| 327 | $hc->tpjornada, |
||
| 328 | true |
||
| 329 | ); |
||
| 330 | $this->dom->addChild( |
||
| 331 | $horContratual, |
||
| 332 | "dscTpJorn", |
||
| 333 | !empty($hc->dsctpjorn) ? $hc->dsctpjorn : null, |
||
| 334 | false |
||
| 335 | ); |
||
| 336 | $this->dom->addChild( |
||
| 337 | $horContratual, |
||
| 338 | "tmpParc", |
||
| 339 | $hc->tmpparc, |
||
| 340 | true |
||
| 341 | ); |
||
| 342 | if (!empty($hc->horario)) { |
||
| 343 | foreach ($hc->horario as $hor) { |
||
| 344 | $horario = $this->dom->createElement("horario"); |
||
| 345 | $this->dom->addChild( |
||
| 346 | $horario, |
||
| 347 | "dia", |
||
| 348 | $hor->dia, |
||
| 349 | true |
||
| 350 | ); |
||
| 351 | $this->dom->addChild( |
||
| 352 | $horario, |
||
| 353 | "codHorContrat", |
||
| 354 | $hor->codhorcontrat, |
||
| 355 | true |
||
| 356 | ); |
||
| 357 | $horContratual->appendChild($horario); |
||
| 358 | } |
||
| 359 | } |
||
| 360 | $infoContrato->appendChild($horContratual); |
||
| 361 | } |
||
| 362 | |||
| 363 | if (!empty($this->std->filiacaosindical)) { |
||
| 364 | foreach ($this->std->filiacaosindical as $fs) { |
||
| 365 | $filiacaoSindical = $this->dom->createElement("filiacaoSindical"); |
||
| 366 | $this->dom->addChild( |
||
| 367 | $filiacaoSindical, |
||
| 368 | "cnpjSindTrab", |
||
| 369 | $fs->cnpjsindtrab, |
||
| 370 | true |
||
| 371 | ); |
||
| 372 | $infoContrato->appendChild($filiacaoSindical); |
||
| 373 | } |
||
| 374 | } |
||
| 375 | |||
| 376 | if (!empty($this->std->alvarajudicial)) { |
||
| 377 | $alvaraJudicial = $this->dom->createElement("alvaraJudicial"); |
||
| 378 | $this->dom->addChild( |
||
| 379 | $alvaraJudicial, |
||
| 380 | "nrProcJud", |
||
| 381 | $this->std->alvarajudicial->nrprocjud, |
||
| 382 | true |
||
| 383 | ); |
||
| 384 | $infoContrato->appendChild($alvaraJudicial); |
||
| 385 | } |
||
| 386 | |||
| 387 | if (!empty($this->std->observacoes)) { |
||
| 388 | foreach ($this->std->observacoes as $obs) { |
||
| 389 | $observacoes = $this->dom->createElement("observacoes"); |
||
| 390 | $this->dom->addChild( |
||
| 391 | $observacoes, |
||
| 392 | "observacao", |
||
| 393 | $obs->observacao, |
||
| 394 | true |
||
| 395 | ); |
||
| 396 | $infoContrato->appendChild($observacoes); |
||
| 397 | } |
||
| 398 | } |
||
| 399 | |||
| 400 | if (!empty($this->std->servpubl)) { |
||
| 401 | $servPubl = $this->dom->createElement("servPubl"); |
||
| 402 | $this->dom->addChild( |
||
| 403 | $servPubl, |
||
| 404 | "mtvAlter", |
||
| 405 | $this->std->servpubl->mtvalter, |
||
| 406 | true |
||
| 407 | ); |
||
| 408 | $infoContrato->appendChild($servPubl); |
||
| 409 | } |
||
| 410 | $altContratual->appendChild($infoContrato); |
||
| 411 | $this->node->appendChild($altContratual); |
||
| 412 | //finalização do xml |
||
| 413 | $this->eSocial->appendChild($this->node); |
||
| 414 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
| 415 | $this->sign(); |
||
| 416 | } |
||
| 417 | |||
| 426 |
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: