| Conditions | 22 |
| Paths | 72 |
| Total Lines | 282 |
| 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 | if ($this->std->indretif == 2) { |
||
| 23 | $this->dom->addChild( |
||
| 24 | $ideEvento, |
||
| 25 | "nrRecibo", |
||
| 26 | $this->std->nrrecibo, |
||
| 27 | true |
||
| 28 | ); |
||
| 29 | } |
||
| 30 | $this->dom->addChild( |
||
| 31 | $ideEvento, |
||
| 32 | "tpAmb", |
||
| 33 | $this->tpAmb, |
||
| 34 | true |
||
| 35 | ); |
||
| 36 | $this->dom->addChild( |
||
| 37 | $ideEvento, |
||
| 38 | "procEmi", |
||
| 39 | $this->procEmi, |
||
| 40 | true |
||
| 41 | ); |
||
| 42 | $this->dom->addChild( |
||
| 43 | $ideEvento, |
||
| 44 | "verProc", |
||
| 45 | $this->verProc, |
||
| 46 | true |
||
| 47 | ); |
||
| 48 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
| 49 | $ideTrabSemVinculo = $this->dom->createElement("ideTrabSemVinculo"); |
||
| 50 | $this->dom->addChild( |
||
| 51 | $ideTrabSemVinculo, |
||
| 52 | "cpfTrab", |
||
| 53 | $this->std->trabsemvinculo->cpftrab, |
||
| 54 | true |
||
| 55 | ); |
||
| 56 | $this->dom->addChild( |
||
| 57 | $ideTrabSemVinculo, |
||
| 58 | "nisTrab", |
||
| 59 | !empty($this->std->trabsemvinculo->nistrab) ? $this->std->trabsemvinculo->nistrab : null, |
||
| 60 | false |
||
| 61 | ); |
||
| 62 | $this->dom->addChild( |
||
| 63 | $ideTrabSemVinculo, |
||
| 64 | "codCateg", |
||
| 65 | $this->std->trabsemvinculo->codcateg, |
||
| 66 | true |
||
| 67 | ); |
||
| 68 | $this->node->appendChild($ideTrabSemVinculo); |
||
| 69 | $infoTSVAlteracao = $this->dom->createElement("infoTSVAlteracao"); |
||
| 70 | $this->dom->addChild( |
||
| 71 | $infoTSVAlteracao, |
||
| 72 | "dtAlteracao", |
||
| 73 | $this->std->tsvalteracao->dtalteracao, |
||
| 74 | true |
||
| 75 | ); |
||
| 76 | $this->dom->addChild( |
||
| 77 | $infoTSVAlteracao, |
||
| 78 | "natAtividade", |
||
| 79 | !empty($this->std->tsvalteracao->natatividade) ? $this->std->tsvalteracao->natatividade : null, |
||
| 80 | false |
||
| 81 | ); |
||
| 82 | $infoComplementares = $this->dom->createElement("infoComplementares"); |
||
| 83 | $infoTSVAlteracao->appendChild($infoComplementares); |
||
| 84 | if (isset($this->std->cargofuncao)) { |
||
| 85 | $cargoFuncao = $this->dom->createElement("cargoFuncao"); |
||
| 86 | $this->dom->addChild( |
||
| 87 | $cargoFuncao, |
||
| 88 | "codCargo", |
||
| 89 | $this->std->cargofuncao->codcargo, |
||
| 90 | true |
||
| 91 | ); |
||
| 92 | $this->dom->addChild( |
||
| 93 | $cargoFuncao, |
||
| 94 | "codFuncao", |
||
| 95 | !empty($this->std->cargofuncao->codfuncao) ? $this->std->cargofuncao->codfuncao : null, |
||
| 96 | false |
||
| 97 | ); |
||
| 98 | $infoComplementares->appendChild($cargoFuncao); |
||
| 99 | } |
||
| 100 | if (isset($this->std->remuneracao)) { |
||
| 101 | $remuneracao = $this->dom->createElement("remuneracao"); |
||
| 102 | $this->dom->addChild( |
||
| 103 | $remuneracao, |
||
| 104 | "vrSalFx", |
||
| 105 | $this->std->remuneracao->vrsalfx, |
||
| 106 | true |
||
| 107 | ); |
||
| 108 | $this->dom->addChild( |
||
| 109 | $remuneracao, |
||
| 110 | "undSalFixo", |
||
| 111 | $this->std->remuneracao->undsalfixo, |
||
| 112 | true |
||
| 113 | ); |
||
| 114 | $this->dom->addChild( |
||
| 115 | $remuneracao, |
||
| 116 | "dscSalVar", |
||
| 117 | !empty($this->std->remuneracao->dscsalvar) ? $this->std->remuneracao->dscsalvar : null, |
||
| 118 | false |
||
| 119 | ); |
||
| 120 | $infoComplementares->appendChild($remuneracao); |
||
| 121 | } |
||
| 122 | if (isset($this->std->estagiario)) { |
||
| 123 | $infoEstagiario = $this->dom->createElement("infoEstagiario"); |
||
| 124 | $this->dom->addChild( |
||
| 125 | $infoEstagiario, |
||
| 126 | "natEstagio", |
||
| 127 | $this->std->estagiario->natestagio, |
||
| 128 | true |
||
| 129 | ); |
||
| 130 | $this->dom->addChild( |
||
| 131 | $infoEstagiario, |
||
| 132 | "nivEstagio", |
||
| 133 | $this->std->estagiario->nivestagio, |
||
| 134 | true |
||
| 135 | ); |
||
| 136 | $this->dom->addChild( |
||
| 137 | $infoEstagiario, |
||
| 138 | "areaAtuacao", |
||
| 139 | !empty($this->std->estagiario->areaatuacao) ? $this->std->estagiario->areaatuacao : null, |
||
| 140 | false |
||
| 141 | ); |
||
| 142 | $this->dom->addChild( |
||
| 143 | $infoEstagiario, |
||
| 144 | "nrApol", |
||
| 145 | !empty($this->std->estagiario->nrapol) ? $this->std->estagiario->nrapol : null, |
||
| 146 | false |
||
| 147 | ); |
||
| 148 | $this->dom->addChild( |
||
| 149 | $infoEstagiario, |
||
| 150 | "vlrBolsa", |
||
| 151 | !empty($this->std->estagiario->vlrbolsa) ? $this->std->estagiario->vlrbolsa : null, |
||
| 152 | false |
||
| 153 | ); |
||
| 154 | $this->dom->addChild( |
||
| 155 | $infoEstagiario, |
||
| 156 | "dtPrevTerm", |
||
| 157 | $this->std->estagiario->dtprevterm, |
||
| 158 | true |
||
| 159 | ); |
||
| 160 | if (isset($this->std->estagiario->instituicao)) { |
||
| 161 | $instEnsino = $this->dom->createElement("instEnsino"); |
||
| 162 | $this->dom->addChild( |
||
| 163 | $instEnsino, |
||
| 164 | "cnpjInstEnsino", |
||
| 165 | $this->std->estagiario->instituicao->cnpjinstensino, |
||
| 166 | true |
||
| 167 | ); |
||
| 168 | $this->dom->addChild( |
||
| 169 | $instEnsino, |
||
| 170 | "nmRazao", |
||
| 171 | $this->std->estagiario->instituicao->nmrazao, |
||
| 172 | true |
||
| 173 | ); |
||
| 174 | $this->dom->addChild( |
||
| 175 | $instEnsino, |
||
| 176 | "dscLograd", |
||
| 177 | !empty($this->std->estagiario->instituicao->dsclograd) ? |
||
| 178 | $this->std->estagiario->instituicao->dsclograd : null, |
||
| 179 | false |
||
| 180 | ); |
||
| 181 | $this->dom->addChild( |
||
| 182 | $instEnsino, |
||
| 183 | "nrLograd", |
||
| 184 | !empty($this->std->estagiario->instituicao->nrlograd) ? |
||
| 185 | $this->std->estagiario->instituicao->nrlograd : null, |
||
| 186 | false |
||
| 187 | ); |
||
| 188 | $this->dom->addChild( |
||
| 189 | $instEnsino, |
||
| 190 | "bairro", |
||
| 191 | !empty($this->std->estagiario->instituicao->bairro) ? $this->std->estagiario->instituicao->bairro : |
||
| 192 | null, |
||
| 193 | false |
||
| 194 | ); |
||
| 195 | $this->dom->addChild( |
||
| 196 | $instEnsino, |
||
| 197 | "cep", |
||
| 198 | !empty($this->std->estagiario->instituicao->cep) ? $this->std->estagiario->instituicao->cep : null, |
||
| 199 | false |
||
| 200 | ); |
||
| 201 | $this->dom->addChild( |
||
| 202 | $instEnsino, |
||
| 203 | "codMunic", |
||
| 204 | !empty($this->std->estagiario->instituicao->codmunic) ? |
||
| 205 | $this->std->estagiario->instituicao->codmunic : null, |
||
| 206 | false |
||
| 207 | ); |
||
| 208 | $this->dom->addChild( |
||
| 209 | $instEnsino, |
||
| 210 | "uf", |
||
| 211 | !empty($this->std->estagiario->instituicao->uf) ? $this->std->estagiario->instituicao->uf : null, |
||
| 212 | false |
||
| 213 | ); |
||
| 214 | $infoEstagiario->appendChild($instEnsino); |
||
| 215 | } |
||
| 216 | if (isset($this->std->estagiario->ageintegracao)) { |
||
| 217 | $ageIntegracao = $this->dom->createElement("ageIntegracao"); |
||
| 218 | $this->dom->addChild( |
||
| 219 | $ageIntegracao, |
||
| 220 | "cnpjAgntInteg", |
||
| 221 | $this->std->estagiario->ageintegracao->cnpjagntinteg, |
||
| 222 | true |
||
| 223 | ); |
||
| 224 | $this->dom->addChild( |
||
| 225 | $ageIntegracao, |
||
| 226 | "nmRazao", |
||
| 227 | $this->std->estagiario->ageintegracao->nmrazao, |
||
| 228 | true |
||
| 229 | ); |
||
| 230 | $this->dom->addChild( |
||
| 231 | $ageIntegracao, |
||
| 232 | "dscLograd", |
||
| 233 | $this->std->estagiario->ageintegracao->dsclograd, |
||
| 234 | true |
||
| 235 | ); |
||
| 236 | $this->dom->addChild( |
||
| 237 | $ageIntegracao, |
||
| 238 | "nrLograd", |
||
| 239 | $this->std->estagiario->ageintegracao->nrlograd, |
||
| 240 | true |
||
| 241 | ); |
||
| 242 | $this->dom->addChild( |
||
| 243 | $ageIntegracao, |
||
| 244 | "bairro", |
||
| 245 | !empty($this->std->estagiario->ageintegracao->bairro) ? |
||
| 246 | $this->std->estagiario->ageintegracao->bairro : null, |
||
| 247 | false |
||
| 248 | ); |
||
| 249 | $this->dom->addChild( |
||
| 250 | $ageIntegracao, |
||
| 251 | "cep", |
||
| 252 | $this->std->estagiario->ageintegracao->cep, |
||
| 253 | true |
||
| 254 | ); |
||
| 255 | $this->dom->addChild( |
||
| 256 | $ageIntegracao, |
||
| 257 | "codMunic", |
||
| 258 | $this->std->estagiario->ageintegracao->codmunic, |
||
| 259 | true |
||
| 260 | ); |
||
| 261 | $this->dom->addChild( |
||
| 262 | $ageIntegracao, |
||
| 263 | "uf", |
||
| 264 | $this->std->estagiario->ageintegracao->uf, |
||
| 265 | true |
||
| 266 | ); |
||
| 267 | $infoEstagiario->appendChild($ageIntegracao); |
||
| 268 | } |
||
| 269 | if (isset($this->std->estagiario->supervisor)) { |
||
| 270 | $supervisorEstagio = $this->dom->createElement("supervisorEstagio"); |
||
| 271 | $this->dom->addChild( |
||
| 272 | $supervisorEstagio, |
||
| 273 | "cpfSupervisor", |
||
| 274 | $this->std->estagiario->supervisor->cpfsupervisor, |
||
| 275 | true |
||
| 276 | ); |
||
| 277 | $this->dom->addChild( |
||
| 278 | $supervisorEstagio, |
||
| 279 | "nmSuperv", |
||
| 280 | $this->std->estagiario->supervisor->nmsuperv, |
||
| 281 | true |
||
| 282 | ); |
||
| 283 | $infoEstagiario->appendChild($supervisorEstagio); |
||
| 284 | } |
||
| 285 | $infoComplementares->appendChild($infoEstagiario); |
||
| 286 | } |
||
| 287 | $this->node->appendChild($infoTSVAlteracao); |
||
| 288 | $this->eSocial->appendChild($this->node); |
||
| 289 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
| 290 | $this->sign(); |
||
| 291 | } |
||
| 292 | |||
| 301 |
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: