| Conditions | 51 |
| Paths | 6528 |
| Total Lines | 390 |
| 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 | "tpAmb", |
||
| 19 | $this->tpAmb, |
||
| 20 | true |
||
| 21 | ); |
||
| 22 | $this->dom->addChild( |
||
| 23 | $ideEvento, |
||
| 24 | "procEmi", |
||
| 25 | $this->procEmi, |
||
| 26 | true |
||
| 27 | ); |
||
| 28 | $this->dom->addChild( |
||
| 29 | $ideEvento, |
||
| 30 | "verProc", |
||
| 31 | $this->verProc, |
||
| 32 | true |
||
| 33 | ); |
||
| 34 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
| 35 | $infoEmpregador = $this->dom->createElement("infoEmpregador"); |
||
| 36 | //periodo |
||
| 37 | $idePeriodo = $this->dom->createElement("idePeriodo"); |
||
| 38 | $this->dom->addChild( |
||
| 39 | $idePeriodo, |
||
| 40 | "iniValid", |
||
| 41 | $this->std->ideperiodo->inivalid, |
||
| 42 | true |
||
| 43 | ); |
||
| 44 | $this->dom->addChild( |
||
| 45 | $idePeriodo, |
||
| 46 | "fimValid", |
||
| 47 | !empty($this->std->ideperiodo->fimvalid) ? $this->std->ideperiodo->fimvalid : '', |
||
| 48 | false |
||
| 49 | ); |
||
| 50 | //infoCadastro |
||
| 51 | if (isset($this->std->infocadastro)) { |
||
| 52 | $cad = $this->std->infocadastro; |
||
| 53 | $infoCadastro = $this->dom->createElement("infoCadastro"); |
||
| 54 | $this->dom->addChild( |
||
| 55 | $infoCadastro, |
||
| 56 | "nmRazao", |
||
| 57 | $cad->nmrazao, |
||
| 58 | true |
||
| 59 | ); |
||
| 60 | $this->dom->addChild( |
||
| 61 | $infoCadastro, |
||
| 62 | "classTrib", |
||
| 63 | $cad->classtrib, |
||
| 64 | true |
||
| 65 | ); |
||
| 66 | $this->dom->addChild( |
||
| 67 | $infoCadastro, |
||
| 68 | "natJurid", |
||
| 69 | !empty($cad->natjurid) ? $cad->natjurid : null, |
||
| 70 | ($this->tpInsc == 1) ? true : false //obrigatorio para pessoa juridica |
||
| 71 | ); |
||
| 72 | $this->dom->addChild( |
||
| 73 | $infoCadastro, |
||
| 74 | "indCoop", |
||
| 75 | isset($cad->indcoop) ? $cad->indcoop : null, |
||
| 76 | ($this->tpInsc == 1) ? true : false //obrigatorio para pessoa juridica |
||
| 77 | ); |
||
| 78 | $this->dom->addChild( |
||
| 79 | $infoCadastro, |
||
| 80 | "indConstr", |
||
| 81 | isset($cad->indconstr) ? $cad->indconstr : null, |
||
| 82 | ($this->tpInsc == 1) ? true : false //obrigatorio para pessoa juridica |
||
| 83 | ); |
||
| 84 | $this->dom->addChild( |
||
| 85 | $infoCadastro, |
||
| 86 | "indDesFolha", |
||
| 87 | $cad->inddesfolha, |
||
| 88 | true |
||
| 89 | ); |
||
| 90 | $this->dom->addChild( |
||
| 91 | $infoCadastro, |
||
| 92 | "indOpcCP", |
||
| 93 | !empty($cad->indopccp) ? $cad->indopccp : null, |
||
| 94 | false |
||
| 95 | ); |
||
| 96 | $this->dom->addChild( |
||
| 97 | $infoCadastro, |
||
| 98 | "indPorte", |
||
| 99 | !empty($cad->indporte) ? $cad->indporte : null, |
||
| 100 | false |
||
| 101 | ); |
||
| 102 | $this->dom->addChild( |
||
| 103 | $infoCadastro, |
||
| 104 | "indOptRegEletron", |
||
| 105 | $cad->indoptregeletron, |
||
| 106 | true |
||
| 107 | ); |
||
| 108 | $this->dom->addChild( |
||
| 109 | $infoCadastro, |
||
| 110 | "indEntEd", |
||
| 111 | !empty($cad->indented) ? $cad->indented : null, |
||
| 112 | false |
||
| 113 | ); |
||
| 114 | $this->dom->addChild( |
||
| 115 | $infoCadastro, |
||
| 116 | "indEtt", |
||
| 117 | !empty($cad->indett) ? $cad->indett : null, |
||
| 118 | false |
||
| 119 | ); |
||
| 120 | $this->dom->addChild( |
||
| 121 | $infoCadastro, |
||
| 122 | "nrRegEtt", |
||
| 123 | !empty($cad->nrregett) ? $cad->nrregett : null, |
||
| 124 | false |
||
| 125 | ); |
||
| 126 | } |
||
| 127 | if (isset($this->std->dadosisencao) && !empty($infoCadastro)) { |
||
| 128 | $cad = $this->std->dadosisencao; |
||
| 129 | $info = $this->dom->createElement("dadosIsencao"); |
||
| 130 | $this->dom->addChild( |
||
| 131 | $info, |
||
| 132 | "ideMinLei", |
||
| 133 | $cad->ideminlei, |
||
| 134 | true |
||
| 135 | ); |
||
| 136 | $this->dom->addChild( |
||
| 137 | $info, |
||
| 138 | "nrCertif", |
||
| 139 | $cad->nrcertif, |
||
| 140 | true |
||
| 141 | ); |
||
| 142 | $this->dom->addChild( |
||
| 143 | $info, |
||
| 144 | "dtEmisCertif", |
||
| 145 | $cad->dtemiscertif, |
||
| 146 | true |
||
| 147 | ); |
||
| 148 | $this->dom->addChild( |
||
| 149 | $info, |
||
| 150 | "dtVencCertif", |
||
| 151 | $cad->dtvenccertif, |
||
| 152 | true |
||
| 153 | ); |
||
| 154 | $this->dom->addChild( |
||
| 155 | $info, |
||
| 156 | "nrProtRenov", |
||
| 157 | !empty($cad->nrprotrenov) ? $cad->nrprotrenov : null, |
||
| 158 | false |
||
| 159 | ); |
||
| 160 | $this->dom->addChild( |
||
| 161 | $info, |
||
| 162 | "dtProtRenov", |
||
| 163 | !empty($cad->dtprotrenov) ? $cad->dtprotrenov : null, |
||
| 164 | false |
||
| 165 | ); |
||
| 166 | $this->dom->addChild( |
||
| 167 | $info, |
||
| 168 | "dtDou", |
||
| 169 | !empty($cad->dtdou) ? $cad->dtdou : null, |
||
| 170 | false |
||
| 171 | ); |
||
| 172 | $this->dom->addChild( |
||
| 173 | $info, |
||
| 174 | "pagDou", |
||
| 175 | !empty($cad->pagdou) ? $cad->pagdou : null, |
||
| 176 | false |
||
| 177 | ); |
||
| 178 | $infoCadastro->appendChild($info); |
||
| 179 | } |
||
| 180 | if (isset($this->std->contato) && !empty($infoCadastro)) { |
||
| 181 | $cad = $this->std->contato; |
||
| 182 | $info = $this->dom->createElement("contato"); |
||
| 183 | $this->dom->addChild( |
||
| 184 | $info, |
||
| 185 | "nmCtt", |
||
| 186 | $cad->nmctt, |
||
| 187 | true |
||
| 188 | ); |
||
| 189 | $this->dom->addChild( |
||
| 190 | $info, |
||
| 191 | "cpfCtt", |
||
| 192 | $cad->cpfctt, |
||
| 193 | true |
||
| 194 | ); |
||
| 195 | $this->dom->addChild( |
||
| 196 | $info, |
||
| 197 | "foneFixo", |
||
| 198 | !empty($cad->fonefixo) ? $cad->fonefixo : '', |
||
| 199 | false |
||
| 200 | ); |
||
| 201 | $this->dom->addChild( |
||
| 202 | $info, |
||
| 203 | "foneCel", |
||
| 204 | !empty($cad->fonecel) ? $cad->fonecel : null, |
||
| 205 | false |
||
| 206 | ); |
||
| 207 | $this->dom->addChild( |
||
| 208 | $info, |
||
| 209 | "email", |
||
| 210 | !empty($cad->email) ? $cad->email : null, |
||
| 211 | false |
||
| 212 | ); |
||
| 213 | $infoCadastro->appendChild($info); |
||
| 214 | if (isset($this->std->infoop) && !empty($infoCadastro)) { |
||
| 215 | $cad = $this->std->infoop; |
||
| 216 | $infoOP = $this->dom->createElement("infoOP"); |
||
| 217 | $this->dom->addChild( |
||
| 218 | $infoOP, |
||
| 219 | "nrSiafi", |
||
| 220 | $cad->nrsiafi, |
||
| 221 | true |
||
| 222 | ); |
||
| 223 | if (isset($this->std->infoefr)) { |
||
| 224 | $cad = $this->std->infoefr; |
||
| 225 | $infoEFR = $this->dom->createElement("infoEFR"); |
||
| 226 | $this->dom->addChild( |
||
| 227 | $infoEFR, |
||
| 228 | "ideEFR", |
||
| 229 | $cad->ideefr, |
||
| 230 | true |
||
| 231 | ); |
||
| 232 | $this->dom->addChild( |
||
| 233 | $infoEFR, |
||
| 234 | "cnpjEFR", |
||
| 235 | !empty($cad->cnpjefr) ? $cad->cnpjefr : null, |
||
| 236 | false |
||
| 237 | ); |
||
| 238 | $infoOP->appendChild($infoEFR); |
||
| 239 | } |
||
| 240 | if (isset($this->std->infoente)) { |
||
| 241 | $cad = $this->std->infoente; |
||
| 242 | $infoEnte = $this->dom->createElement("infoEnte"); |
||
| 243 | $this->dom->addChild( |
||
| 244 | $infoEnte, |
||
| 245 | "nmEnte", |
||
| 246 | $cad->nmente, |
||
| 247 | true |
||
| 248 | ); |
||
| 249 | $this->dom->addChild( |
||
| 250 | $infoEnte, |
||
| 251 | "uf", |
||
| 252 | $cad->uf, |
||
| 253 | true |
||
| 254 | ); |
||
| 255 | $this->dom->addChild( |
||
| 256 | $infoEnte, |
||
| 257 | "codMunic", |
||
| 258 | !empty($cad->codmunic) ? $cad->codmunic : null, |
||
| 259 | false |
||
| 260 | ); |
||
| 261 | $this->dom->addChild( |
||
| 262 | $infoEnte, |
||
| 263 | "indRPPS", |
||
| 264 | $cad->indrpps, |
||
| 265 | true |
||
| 266 | ); |
||
| 267 | $this->dom->addChild( |
||
| 268 | $infoEnte, |
||
| 269 | "subteto", |
||
| 270 | $cad->subteto, |
||
| 271 | true |
||
| 272 | ); |
||
| 273 | $this->dom->addChild( |
||
| 274 | $infoEnte, |
||
| 275 | "vrSubteto", |
||
| 276 | number_format($cad->vrsubteto, 2, ".", ""), |
||
| 277 | true |
||
| 278 | ); |
||
| 279 | $infoOP->appendChild($infoEnte); |
||
| 280 | } |
||
| 281 | $infoCadastro->appendChild($infoOP); |
||
| 282 | } |
||
| 283 | } |
||
| 284 | if (isset($this->std->infoorginternacional) && !empty($infoCadastro)) { |
||
| 285 | $cad = $this->std->infoorginternacional; |
||
| 286 | $info = $this->dom->createElement("infoOrgInternacional"); |
||
| 287 | $this->dom->addChild( |
||
| 288 | $info, |
||
| 289 | "indAcordoIsenMulta", |
||
| 290 | $cad->indacordoisenmulta, |
||
| 291 | true |
||
| 292 | ); |
||
| 293 | $infoCadastro->appendChild($info); |
||
| 294 | } |
||
| 295 | if (isset($this->std->softwarehouse) && !empty($infoCadastro)) { |
||
| 296 | foreach ($this->std->softwarehouse as $sh) { |
||
| 297 | $info = $this->dom->createElement("softwareHouse"); |
||
| 298 | $this->dom->addChild( |
||
| 299 | $info, |
||
| 300 | "cnpjSoftHouse", |
||
| 301 | $sh->cnpjsofthouse, |
||
| 302 | true |
||
| 303 | ); |
||
| 304 | $this->dom->addChild( |
||
| 305 | $info, |
||
| 306 | "nmRazao", |
||
| 307 | $sh->nmrazao, |
||
| 308 | true |
||
| 309 | ); |
||
| 310 | $this->dom->addChild( |
||
| 311 | $info, |
||
| 312 | "nmCont", |
||
| 313 | $sh->nmcont, |
||
| 314 | true |
||
| 315 | ); |
||
| 316 | $this->dom->addChild( |
||
| 317 | $info, |
||
| 318 | "telefone", |
||
| 319 | $sh->telefone, |
||
| 320 | true |
||
| 321 | ); |
||
| 322 | $this->dom->addChild( |
||
| 323 | $info, |
||
| 324 | "email", |
||
| 325 | !empty($sh->email) ? $sh->email : null, |
||
| 326 | false |
||
| 327 | ); |
||
| 328 | $infoCadastro->appendChild($info); |
||
| 329 | } |
||
| 330 | if (isset($this->std->situacaopj)) { |
||
| 331 | $infoComplementares = $this->dom->createElement("infoComplementares"); |
||
| 332 | $sh = $this->std->situacaopj; |
||
| 333 | $info = $this->dom->createElement("situacaoPJ"); |
||
| 334 | $this->dom->addChild( |
||
| 335 | $info, |
||
| 336 | "indSitPJ", |
||
| 337 | $sh->indsitpj, |
||
| 338 | true |
||
| 339 | ); |
||
| 340 | $infoComplementares->appendChild($info); |
||
| 341 | } elseif (isset($this->std->situacaopf)) { |
||
| 342 | $infoComplementares = $this->dom->createElement("infoComplementares"); |
||
| 343 | $sh = $this->std->situacaopf; |
||
| 344 | $info = $this->dom->createElement("situacaoPF"); |
||
| 345 | $this->dom->addChild( |
||
| 346 | $info, |
||
| 347 | "indSitPF", |
||
| 348 | $sh->indsitpf, |
||
| 349 | true |
||
| 350 | ); |
||
| 351 | $infoComplementares->appendChild($info); |
||
| 352 | } |
||
| 353 | } |
||
| 354 | if (isset($this->std->novavalidade)) { |
||
| 355 | $sh = $this->std->novavalidade; |
||
| 356 | $novavalidade = $this->dom->createElement("novaValidade"); |
||
| 357 | $this->dom->addChild( |
||
| 358 | $novavalidade, |
||
| 359 | "iniValid", |
||
| 360 | $sh->inivalid, |
||
| 361 | true |
||
| 362 | ); |
||
| 363 | $this->dom->addChild( |
||
| 364 | $novavalidade, |
||
| 365 | "fimValid", |
||
| 366 | !empty($sh->fimValid) ? $sh->fimValid : null, |
||
| 367 | false |
||
| 368 | ); |
||
| 369 | } |
||
| 370 | switch ($this->std->modo) { |
||
| 371 | case "ALT": |
||
| 372 | $node = $this->dom->createElement("alteracao"); |
||
| 373 | $node->appendChild($idePeriodo); |
||
| 374 | if (isset($infoComplementares) && isset($infoCadastro)) { |
||
| 375 | $infoCadastro->appendChild($infoComplementares); |
||
| 376 | } |
||
| 377 | isset($infoCadastro) ? $node->appendChild($infoCadastro) : null; |
||
| 378 | isset($novavalidade) ? $node->appendChild($novavalidade) : null; |
||
| 379 | break; |
||
| 380 | case "EXC": |
||
| 381 | $node = $this->dom->createElement("exclusao"); |
||
| 382 | $node->appendChild($idePeriodo); |
||
| 383 | break; |
||
| 384 | case "INC": |
||
| 385 | default: |
||
| 386 | $node = $this->dom->createElement("inclusao"); |
||
| 387 | $node->appendChild($idePeriodo); |
||
| 388 | if (isset($infoComplementares) && isset($infoCadastro)) { |
||
| 389 | $infoCadastro->appendChild($infoComplementares); |
||
| 390 | } |
||
| 391 | isset($infoCadastro) ? $node->appendChild($infoCadastro) : null; |
||
| 392 | } |
||
| 393 | $infoEmpregador->appendChild($node); |
||
| 394 | $this->node->appendChild($infoEmpregador); |
||
| 395 | //finalização do xml |
||
| 396 | $this->eSocial->appendChild($this->node); |
||
| 397 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
| 398 | $this->sign(); |
||
| 399 | } |
||
| 400 | |||
| 608 |
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: