| Conditions | 2 |
| Paths | 2 |
| Total Lines | 86 |
| 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 |
||
| 18 | protected function toNodeS100() |
||
| 19 | { |
||
| 20 | $ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); |
||
| 21 | //o idEvento pode variar de evento para evento |
||
| 22 | //então cada factory individualmente terá de construir o seu |
||
| 23 | $ideEvento = $this->dom->createElement("ideEvento"); |
||
| 24 | $this->dom->addChild( |
||
| 25 | $ideEvento, |
||
| 26 | "indRetif", |
||
| 27 | $this->std->indretif, |
||
| 28 | true |
||
| 29 | ); |
||
| 30 | if ($this->std->indretif == 2) { |
||
| 31 | $this->dom->addChild( |
||
| 32 | $ideEvento, |
||
| 33 | "nrRecibo", |
||
| 34 | $this->std->nrrecibo, |
||
| 35 | true |
||
| 36 | ); |
||
| 37 | } |
||
| 38 | $this->dom->addChild( |
||
| 39 | $ideEvento, |
||
| 40 | "tpAmb", |
||
| 41 | $this->tpAmb, |
||
| 42 | true |
||
| 43 | ); |
||
| 44 | $this->dom->addChild( |
||
| 45 | $ideEvento, |
||
| 46 | "procEmi", |
||
| 47 | $this->procEmi, |
||
| 48 | true |
||
| 49 | ); |
||
| 50 | $this->dom->addChild( |
||
| 51 | $ideEvento, |
||
| 52 | "verProc", |
||
| 53 | $this->verProc, |
||
| 54 | true |
||
| 55 | ); |
||
| 56 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
| 57 | |||
| 58 | $ideBeneficio = $this->dom->createElement("ideBeneficio"); |
||
| 59 | $this->dom->addChild( |
||
| 60 | $ideBeneficio, |
||
| 61 | "cpfBenef", |
||
| 62 | $this->std->cpfbenef, |
||
| 63 | true |
||
| 64 | ); |
||
| 65 | $this->dom->addChild( |
||
| 66 | $ideBeneficio, |
||
| 67 | "nrBeneficio", |
||
| 68 | $this->std->nrbeneficio, |
||
| 69 | true |
||
| 70 | ); |
||
| 71 | $this->node->appendChild($ideBeneficio); |
||
| 72 | |||
| 73 | $infoBenTermino = $this->dom->createElement("infoBenTermino"); |
||
| 74 | $this->dom->addChild( |
||
| 75 | $infoBenTermino, |
||
| 76 | "dtTermBeneficio", |
||
| 77 | $this->std->dttermbeneficio, |
||
| 78 | true |
||
| 79 | ); |
||
| 80 | $this->dom->addChild( |
||
| 81 | $infoBenTermino, |
||
| 82 | "mtvTermino", |
||
| 83 | $this->std->mtvtermino, |
||
| 84 | true |
||
| 85 | ); |
||
| 86 | $this->dom->addChild( |
||
| 87 | $infoBenTermino, |
||
| 88 | "cnpjOrgaoSuc", |
||
| 89 | $this->std->cnpjorgaosuc, |
||
| 90 | false |
||
| 91 | ); |
||
| 92 | $this->dom->addChild( |
||
| 93 | $infoBenTermino, |
||
| 94 | "novoCPF", |
||
| 95 | $this->std->novocpf, |
||
| 96 | false |
||
| 97 | ); |
||
| 98 | $this->node->appendChild($infoBenTermino); |
||
| 99 | //finalização do xml |
||
| 100 | $this->eSocial->appendChild($this->node); |
||
| 101 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
| 102 | $this->sign(); |
||
| 103 | } |
||
| 104 | } |
||
| 105 |
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: