| Conditions | 4 |
| Paths | 4 |
| Total Lines | 76 |
| 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 | $infoExclusao = $this->dom->createElement("infoExclusao"); |
||
| 37 | $this->dom->addChild( |
||
| 38 | $infoExclusao, |
||
| 39 | "tpEvento", |
||
| 40 | $this->std->infoexclusao->tpevento, |
||
| 41 | true |
||
| 42 | ); |
||
| 43 | $this->dom->addChild( |
||
| 44 | $infoExclusao, |
||
| 45 | "nrRecEvt", |
||
| 46 | $this->std->infoexclusao->nrrecevt, |
||
| 47 | true |
||
| 48 | ); |
||
| 49 | if (!empty($this->std->idetrabalhador)) { |
||
| 50 | $ideTrabalhador = $this->dom->createElement("ideTrabalhador"); |
||
| 51 | $this->dom->addChild( |
||
| 52 | $ideTrabalhador, |
||
| 53 | "cpfTrab", |
||
| 54 | $this->std->idetrabalhador->cpftrab, |
||
| 55 | true |
||
| 56 | ); |
||
| 57 | $this->dom->addChild( |
||
| 58 | $ideTrabalhador, |
||
| 59 | "nisTrab", |
||
| 60 | !empty($this->std->idetrabalhador->nistrab) ? $this->std->idetrabalhador->nistrab : null, |
||
| 61 | false |
||
| 62 | ); |
||
| 63 | $infoExclusao->appendChild($ideTrabalhador); |
||
| 64 | } |
||
| 65 | if (!empty($this->std->idefolhapagto)) { |
||
| 66 | $ideFolhaPagto = $this->dom->createElement("ideFolhaPagto"); |
||
| 67 | $this->dom->addChild( |
||
| 68 | $ideFolhaPagto, |
||
| 69 | "indApuracao", |
||
| 70 | $this->std->idefolhapagto->indapuracao, |
||
| 71 | true |
||
| 72 | ); |
||
| 73 | $this->dom->addChild( |
||
| 74 | $ideFolhaPagto, |
||
| 75 | "perApur", |
||
| 76 | $this->std->idefolhapagto->perapur, |
||
| 77 | true |
||
| 78 | ); |
||
| 79 | $infoExclusao->appendChild($ideFolhaPagto); |
||
| 80 | } |
||
| 81 | $this->node->appendChild($infoExclusao); |
||
| 82 | $this->eSocial->appendChild($this->node); |
||
| 83 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
| 84 | $this->sign(); |
||
| 85 | } |
||
| 86 | |||
| 161 |
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: