| Conditions | 3 |
| Paths | 4 |
| Total Lines | 70 |
| 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 |
||
| 90 | protected function toNodeS100() |
||
| 91 | { |
||
| 92 | $ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); |
||
| 93 | //o idEvento pode variar de evento para evento |
||
| 94 | //então cada factory individualmente terá de construir o seu |
||
| 95 | $ideEvento = $this->dom->createElement("ideEvento"); |
||
| 96 | $this->dom->addChild( |
||
| 97 | $ideEvento, |
||
| 98 | "tpAmb", |
||
| 99 | $this->tpAmb, |
||
| 100 | true |
||
| 101 | ); |
||
| 102 | $this->dom->addChild( |
||
| 103 | $ideEvento, |
||
| 104 | "procEmi", |
||
| 105 | $this->procEmi, |
||
| 106 | true |
||
| 107 | ); |
||
| 108 | $this->dom->addChild( |
||
| 109 | $ideEvento, |
||
| 110 | "verProc", |
||
| 111 | $this->verProc, |
||
| 112 | true |
||
| 113 | ); |
||
| 114 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
| 115 | |||
| 116 | $infoExclusao = $this->dom->createElement("infoExclusao"); |
||
| 117 | $this->dom->addChild( |
||
| 118 | $infoExclusao, |
||
| 119 | "tpEvento", |
||
| 120 | $this->std->infoexclusao->tpevento, |
||
| 121 | true |
||
| 122 | ); |
||
| 123 | $this->dom->addChild( |
||
| 124 | $infoExclusao, |
||
| 125 | "nrRecEvt", |
||
| 126 | $this->std->infoexclusao->nrrecevt, |
||
| 127 | true |
||
| 128 | ); |
||
| 129 | if (!empty($this->std->idetrabalhador)) { |
||
| 130 | $ideTrabalhador = $this->dom->createElement("ideTrabalhador"); |
||
| 131 | $this->dom->addChild( |
||
| 132 | $ideTrabalhador, |
||
| 133 | "cpfTrab", |
||
| 134 | $this->std->idetrabalhador->cpftrab, |
||
| 135 | true |
||
| 136 | ); |
||
| 137 | $infoExclusao->appendChild($ideTrabalhador); |
||
| 138 | } |
||
| 139 | if (!empty($this->std->idefolhapagto)) { |
||
| 140 | $ideFolhaPagto = $this->dom->createElement("ideFolhaPagto"); |
||
| 141 | $this->dom->addChild( |
||
| 142 | $ideFolhaPagto, |
||
| 143 | "indApuracao", |
||
| 144 | $this->std->idefolhapagto->indapuracao, |
||
| 145 | true |
||
| 146 | ); |
||
| 147 | $this->dom->addChild( |
||
| 148 | $ideFolhaPagto, |
||
| 149 | "perApur", |
||
| 150 | $this->std->idefolhapagto->perapur, |
||
| 151 | true |
||
| 152 | ); |
||
| 153 | $infoExclusao->appendChild($ideFolhaPagto); |
||
| 154 | } |
||
| 155 | $this->node->appendChild($infoExclusao); |
||
| 156 | $this->eSocial->appendChild($this->node); |
||
| 157 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
| 158 | $this->sign(); |
||
| 159 | } |
||
| 160 | } |
||
| 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: