Conditions | 13 |
Paths | 30 |
Total Lines | 166 |
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 |
||
180 | protected function toNodeS100() |
||
181 | { |
||
182 | $ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); |
||
183 | //o idEvento pode variar de evento para evento |
||
184 | //então cada factory individualmente terá de construir o seu |
||
185 | $ideEvento = $this->dom->createElement("ideEvento"); |
||
186 | $this->dom->addChild( |
||
187 | $ideEvento, |
||
188 | "tpAmb", |
||
189 | $this->tpAmb, |
||
190 | true |
||
191 | ); |
||
192 | $this->dom->addChild( |
||
193 | $ideEvento, |
||
194 | "procEmi", |
||
195 | $this->procEmi, |
||
196 | true |
||
197 | ); |
||
198 | $this->dom->addChild( |
||
199 | $ideEvento, |
||
200 | "verProc", |
||
201 | $this->verProc, |
||
202 | true |
||
203 | ); |
||
204 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
205 | |||
206 | //tag deste evento em particular |
||
207 | $info = $this->dom->createElement("infoProcesso"); |
||
208 | |||
209 | //tag comum a todos os modos |
||
210 | $ide = $this->dom->createElement("ideProcesso"); |
||
211 | $this->dom->addChild( |
||
212 | $ide, |
||
213 | "tpProc", |
||
214 | $this->std->tpproc, |
||
215 | true |
||
216 | ); |
||
217 | $this->dom->addChild( |
||
218 | $ide, |
||
219 | "nrProc", |
||
220 | $this->std->nrproc, |
||
221 | true |
||
222 | ); |
||
223 | $this->dom->addChild( |
||
224 | $ide, |
||
225 | "iniValid", |
||
226 | $this->std->inivalid, |
||
227 | true |
||
228 | ); |
||
229 | $this->dom->addChild( |
||
230 | $ide, |
||
231 | "fimValid", |
||
232 | ! empty($this->std->fimvalid) ? $this->std->fimvalid : null, |
||
233 | false |
||
234 | ); |
||
235 | //seleção do modo |
||
236 | if ($this->std->modo == 'INC') { |
||
237 | $node = $this->dom->createElement("inclusao"); |
||
238 | } elseif ($this->std->modo == 'ALT') { |
||
239 | $node = $this->dom->createElement("alteracao"); |
||
240 | } else { |
||
241 | $node = $this->dom->createElement("exclusao"); |
||
242 | } |
||
243 | $node->appendChild($ide); |
||
244 | |||
245 | if ($this->std->modo != 'EXC') { |
||
246 | $dados = $this->dom->createElement("dadosProc"); |
||
247 | $this->dom->addChild( |
||
248 | $dados, |
||
249 | "indAutoria", |
||
250 | !empty($this->std->dadosproc->indautoria) |
||
251 | ? $this->std->dadosproc->indautoria |
||
252 | : null, |
||
253 | false |
||
254 | ); |
||
255 | $this->dom->addChild( |
||
256 | $dados, |
||
257 | "indMatProc", |
||
258 | $this->std->dadosproc->indmatproc, |
||
259 | true |
||
260 | ); |
||
261 | $this->dom->addChild( |
||
262 | $dados, |
||
263 | "observacao", |
||
264 | !empty($this->std->dadosproc->observacao) ? $this->std->dadosproc->observacao : null, |
||
265 | false |
||
266 | ); |
||
267 | if (! empty($this->std->dadosproc->dadosprocjud)) { |
||
268 | $dadosProcJud = $this->dom->createElement("dadosProcJud"); |
||
269 | $this->dom->addChild( |
||
270 | $dadosProcJud, |
||
271 | "ufVara", |
||
272 | $this->std->dadosproc->dadosprocjud->ufvara, |
||
273 | true |
||
274 | ); |
||
275 | $this->dom->addChild( |
||
276 | $dadosProcJud, |
||
277 | "codMunic", |
||
278 | $this->std->dadosproc->dadosprocjud->codmunic, |
||
279 | true |
||
280 | ); |
||
281 | $this->dom->addChild( |
||
282 | $dadosProcJud, |
||
283 | "idVara", |
||
284 | $this->std->dadosproc->dadosprocjud->idvara, |
||
285 | true |
||
286 | ); |
||
287 | $dados->appendChild($dadosProcJud); |
||
288 | } |
||
289 | if (! empty($this->std->dadosproc->infosusp)) { |
||
290 | foreach ($this->std->dadosproc->infosusp as $susp) { |
||
291 | $infoSusp = $this->dom->createElement("infoSusp"); |
||
292 | $this->dom->addChild( |
||
293 | $infoSusp, |
||
294 | "codSusp", |
||
295 | $susp->codsusp, |
||
296 | true |
||
297 | ); |
||
298 | $this->dom->addChild( |
||
299 | $infoSusp, |
||
300 | "indSusp", |
||
301 | $susp->indsusp, |
||
302 | true |
||
303 | ); |
||
304 | $this->dom->addChild( |
||
305 | $infoSusp, |
||
306 | "dtDecisao", |
||
307 | $susp->dtdecisao, |
||
308 | true |
||
309 | ); |
||
310 | $this->dom->addChild( |
||
311 | $infoSusp, |
||
312 | "indDeposito", |
||
313 | $susp->inddeposito, |
||
314 | true |
||
315 | ); |
||
316 | $dados->appendChild($infoSusp); |
||
317 | } |
||
318 | } |
||
319 | $node->appendChild($dados); |
||
320 | } |
||
321 | if (! empty($this->std->novavalidade) && $this->std->modo == 'ALT') { |
||
322 | $newVal = $this->std->novavalidade; |
||
323 | $novaValidade = $this->dom->createElement("novaValidade"); |
||
324 | $this->dom->addChild( |
||
325 | $ideRubrica, |
||
326 | "iniValid", |
||
327 | $newVal->inivalid, |
||
328 | true |
||
329 | ); |
||
330 | $this->dom->addChild( |
||
331 | $ideRubrica, |
||
332 | "fimValid", |
||
333 | ! empty($newVal->fimvalid) ? $newVal->fimvalid : null, |
||
334 | false |
||
335 | ); |
||
336 | $node->appendChild($novaValidade); |
||
337 | } |
||
338 | |||
339 | $info->appendChild($node); |
||
340 | //finalização do xml |
||
341 | $this->node->appendChild($info); |
||
342 | $this->eSocial->appendChild($this->node); |
||
343 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
344 | $this->sign(); |
||
345 | } |
||
346 | } |
||
347 |
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: