| Conditions | 23 |
| Paths | 9222 |
| Total Lines | 263 |
| 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 | |||
| 36 | //tag deste evento em particular |
||
| 37 | $infoEstab = $this->dom->createElement("infoEstab"); |
||
| 38 | |||
| 39 | //tag comum a todos os modos |
||
| 40 | $ideEstab = $this->dom->createElement("ideEstab"); |
||
| 41 | $this->dom->addChild( |
||
| 42 | $ideEstab, |
||
| 43 | "tpInsc", |
||
| 44 | $this->std->tpinsc, |
||
| 45 | true |
||
| 46 | ); |
||
| 47 | $this->dom->addChild( |
||
| 48 | $ideEstab, |
||
| 49 | "nrInsc", |
||
| 50 | $this->std->nrinsc, |
||
| 51 | true |
||
| 52 | ); |
||
| 53 | $this->dom->addChild( |
||
| 54 | $ideEstab, |
||
| 55 | "iniValid", |
||
| 56 | $this->std->inivalid, |
||
| 57 | true |
||
| 58 | ); |
||
| 59 | $this->dom->addChild( |
||
| 60 | $ideEstab, |
||
| 61 | "fimValid", |
||
| 62 | ! empty($this->std->fimvalid) ? $this->std->fimvalid : null, |
||
| 63 | false |
||
| 64 | ); |
||
| 65 | |||
| 66 | if ($this->std->modo == 'INC') { |
||
| 67 | $node = $this->dom->createElement("inclusao"); |
||
| 68 | } elseif ($this->std->modo == 'ALT') { |
||
| 69 | $node = $this->dom->createElement("alteracao"); |
||
| 70 | } else { |
||
| 71 | $node = $this->dom->createElement("exclusao"); |
||
| 72 | } |
||
| 73 | $node->appendChild($ideEstab); |
||
| 74 | |||
| 75 | if (! empty($this->std->dadosestab)) { |
||
| 76 | $dadosEstab = $this->dom->createElement("dadosEstab"); |
||
| 77 | $this->dom->addChild( |
||
| 78 | $dadosEstab, |
||
| 79 | "cnaePrep", |
||
| 80 | $this->std->dadosestab->cnaeprep, |
||
| 81 | true |
||
| 82 | ); |
||
| 83 | $aliqGilrat = $this->dom->createElement("aliqGilrat"); |
||
| 84 | $this->dom->addChild( |
||
| 85 | $aliqGilrat, |
||
| 86 | "aliqRat", |
||
| 87 | $this->std->dadosestab->aliqgilrat->aliqrat, |
||
| 88 | true |
||
| 89 | ); |
||
| 90 | $fap = ! empty($this->std->dadosestab->aliqgilrat->fap) ? $this->std->dadosestab->aliqgilrat->fap : null; |
||
| 91 | if ($fap) { |
||
| 92 | $fap = number_format($fap, 4, '.', ''); |
||
| 93 | } |
||
| 94 | $this->dom->addChild( |
||
| 95 | $aliqGilrat, |
||
| 96 | "fap", |
||
| 97 | $fap, |
||
| 98 | false |
||
| 99 | ); |
||
| 100 | $aliqrata = ! empty($this->std->dadosestab->aliqgilrat->aliqratajust) |
||
| 101 | ? $this->std->dadosestab->aliqgilrat->aliqratajust |
||
| 102 | : null; |
||
| 103 | if ($aliqrata) { |
||
| 104 | $aliqrata = number_format($aliqrata, 4, '.', ''); |
||
| 105 | } |
||
| 106 | $this->dom->addChild( |
||
| 107 | $aliqGilrat, |
||
| 108 | "aliqRatAjust", |
||
| 109 | $aliqrata, |
||
| 110 | false |
||
| 111 | ); |
||
| 112 | if (! empty($this->std->dadosestab->aliqgilrat->procadmjudrat)) { |
||
| 113 | $procAdmJudRat = $this->dom->createElement("procAdmJudRat"); |
||
| 114 | $this->dom->addChild( |
||
| 115 | $procAdmJudRat, |
||
| 116 | "tpProc", |
||
| 117 | $this->std->dadosestab->aliqgilrat->procadmjudrat->tpproc, |
||
| 118 | true |
||
| 119 | ); |
||
| 120 | $this->dom->addChild( |
||
| 121 | $procAdmJudRat, |
||
| 122 | "nrProc", |
||
| 123 | $this->std->dadosestab->aliqgilrat->procadmjudrat->nrproc, |
||
| 124 | true |
||
| 125 | ); |
||
| 126 | $this->dom->addChild( |
||
| 127 | $procAdmJudRat, |
||
| 128 | "codSusp", |
||
| 129 | $this->std->dadosestab->aliqgilrat->procadmjudrat->codsusp, |
||
| 130 | true |
||
| 131 | ); |
||
| 132 | $aliqGilrat->appendChild($procAdmJudRat); |
||
| 133 | } |
||
| 134 | if (! empty($this->std->dadosestab->aliqgilrat->procadmjudfap)) { |
||
| 135 | $procAdmJudFap = $this->dom->createElement("procAdmJudFap"); |
||
| 136 | $this->dom->addChild( |
||
| 137 | $procAdmJudFap, |
||
| 138 | "tpProc", |
||
| 139 | $this->std->dadosestab->aliqgilrat->procadmjudfap->tpproc, |
||
| 140 | true |
||
| 141 | ); |
||
| 142 | $this->dom->addChild( |
||
| 143 | $procAdmJudFap, |
||
| 144 | "nrProc", |
||
| 145 | $this->std->dadosestab->aliqgilrat->procadmjudfap->nrproc, |
||
| 146 | true |
||
| 147 | ); |
||
| 148 | $this->dom->addChild( |
||
| 149 | $procAdmJudFap, |
||
| 150 | "codSusp", |
||
| 151 | $this->std->dadosestab->aliqgilrat->procadmjudfap->codsusp, |
||
| 152 | true |
||
| 153 | ); |
||
| 154 | $aliqGilrat->appendChild($procAdmJudFap); |
||
| 155 | } |
||
| 156 | $dadosEstab->appendChild($aliqGilrat); |
||
| 157 | |||
| 158 | if (! empty($this->std->dadosestab->infocaepf)) { |
||
| 159 | $infoCaepf = $this->dom->createElement("infoCaepf"); |
||
| 160 | $this->dom->addChild( |
||
| 161 | $infoCaepf, |
||
| 162 | "tpCaepf", |
||
| 163 | $this->std->dadosestab->infocaepf->tpcaepf, |
||
| 164 | true |
||
| 165 | ); |
||
| 166 | $dadosEstab->appendChild($infoCaepf); |
||
| 167 | } |
||
| 168 | |||
| 169 | if (! empty($this->std->dadosestab->infoobra)) { |
||
| 170 | $infoObra = $this->dom->createElement("infoObra"); |
||
| 171 | $this->dom->addChild( |
||
| 172 | $infoObra, |
||
| 173 | "indSubstPatrObra", |
||
| 174 | $this->std->dadosestab->infoobra->indsubstpatrobra, |
||
| 175 | true |
||
| 176 | ); |
||
| 177 | $dadosEstab->appendChild($infoObra); |
||
| 178 | } |
||
| 179 | |||
| 180 | $infoTrab = $this->dom->createElement("infoTrab"); |
||
| 181 | $this->dom->addChild( |
||
| 182 | $infoTrab, |
||
| 183 | "regPt", |
||
| 184 | $this->std->dadosestab->infotrab->regpt, |
||
| 185 | true |
||
| 186 | ); |
||
| 187 | if (! empty($this->std->dadosestab->infoapr)) { |
||
| 188 | $infoApr = $this->dom->createElement("infoApr"); |
||
| 189 | $this->dom->addChild( |
||
| 190 | $infoApr, |
||
| 191 | "contApr", |
||
| 192 | $this->std->dadosestab->infotrab->infoapr->contapr, |
||
| 193 | true |
||
| 194 | ); |
||
| 195 | $this->dom->addChild( |
||
| 196 | $infoApr, |
||
| 197 | "nrProcJud", |
||
| 198 | ! empty($this->std->dadosestab->infotrab->infoapr->nrprocjud) |
||
| 199 | ? $this->std->dadosestab->infotrab->infoapr->nrprocjud |
||
| 200 | : null, |
||
| 201 | false |
||
| 202 | ); |
||
| 203 | $this->dom->addChild( |
||
| 204 | $infoApr, |
||
| 205 | "contEntEd", |
||
| 206 | ! empty($this->std->dadosestab->infotrab->infoapr->contented) |
||
| 207 | ? $this->std->dadosestab->infotrab->infoapr->contented |
||
| 208 | : null, |
||
| 209 | false |
||
| 210 | ); |
||
| 211 | |||
| 212 | if (! empty($this->std->dadosestab->infotrab->infoapr->infoenteduc)) { |
||
| 213 | foreach ($this->std->dadosestab->infotrab->infoapr->infoenteduc as $edu) { |
||
| 214 | $infoEntEduc = $this->dom->createElement("infoEntEduc"); |
||
| 215 | $this->dom->addChild( |
||
| 216 | $infoEntEduc, |
||
| 217 | "nrInsc", |
||
| 218 | $edu->nrinsc, |
||
| 219 | true |
||
| 220 | ); |
||
| 221 | $infoApr->appendChild($infoEntEduc); |
||
| 222 | } |
||
| 223 | } |
||
| 224 | |||
| 225 | $infoTrab->appendChild($infoApr); |
||
| 226 | } |
||
| 227 | if (! empty($this->std->dadosestab->infotrab->infopdc)) { |
||
| 228 | $infoPCD = $this->dom->createElement("infoPCD"); |
||
| 229 | $this->dom->addChild( |
||
| 230 | $infoPCD, |
||
| 231 | "contPCD", |
||
| 232 | $this->std->dadosestab->infotrab->infopdc->contpdc, |
||
| 233 | true |
||
| 234 | ); |
||
| 235 | $this->dom->addChild( |
||
| 236 | $infoPCD, |
||
| 237 | "nrProcJud", |
||
| 238 | ! empty($this->std->dadosestab->infotrab->infopdc->nrprocjud) |
||
| 239 | ? $this->std->dadosestab->infotrab->infopdc->nrprocjud |
||
| 240 | : null, |
||
| 241 | false |
||
| 242 | ); |
||
| 243 | $infoTrab->appendChild($infoPCD); |
||
| 244 | } |
||
| 245 | $dadosEstab->appendChild($infoTrab); |
||
| 246 | $node->appendChild($dadosEstab); |
||
| 247 | } |
||
| 248 | |||
| 249 | if (! empty($this->std->novavalidade) && $this->std->modo == 'ALT') { |
||
| 250 | $newVal = $this->std->novavalidade; |
||
| 251 | $novaValidade = $this->dom->createElement("novaValidade"); |
||
| 252 | $this->dom->addChild( |
||
| 253 | $novaValidade, |
||
| 254 | "iniValid", |
||
| 255 | $newVal->inivalid, |
||
| 256 | true |
||
| 257 | ); |
||
| 258 | $this->dom->addChild( |
||
| 259 | $novaValidade, |
||
| 260 | "fimValid", |
||
| 261 | ! empty($newVal->fimvalid) ? $newVal->fimvalid : null, |
||
| 262 | false |
||
| 263 | ); |
||
| 264 | $node->appendChild($novaValidade); |
||
| 265 | } |
||
| 266 | $infoEstab = $this->dom->createElement("infoEstab"); |
||
| 267 | $infoEstab->appendChild($node); |
||
| 268 | //finalização do xml |
||
| 269 | $this->node->appendChild($infoEstab); |
||
| 270 | $this->eSocial->appendChild($this->node); |
||
| 271 | $this->sign(); |
||
| 272 | } |
||
| 273 | |||
| 499 |
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: