| Conditions | 6 |
| Paths | 4 |
| Total Lines | 115 |
| 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 | "indRetif", |
||
| 19 | $this->std->indretif, |
||
| 20 | true |
||
| 21 | ); |
||
| 22 | $this->dom->addChild( |
||
| 23 | $ideEvento, |
||
| 24 | "nrRecibo", |
||
| 25 | ! empty($this->std->nrrecibo) ? $this->std->nrrecibo : null, |
||
| 26 | false |
||
| 27 | ); |
||
| 28 | $this->dom->addChild( |
||
| 29 | $ideEvento, |
||
| 30 | "tpAmb", |
||
| 31 | $this->tpAmb, |
||
| 32 | true |
||
| 33 | ); |
||
| 34 | $this->dom->addChild( |
||
| 35 | $ideEvento, |
||
| 36 | "procEmi", |
||
| 37 | $this->procEmi, |
||
| 38 | true |
||
| 39 | ); |
||
| 40 | $this->dom->addChild( |
||
| 41 | $ideEvento, |
||
| 42 | "verProc", |
||
| 43 | $this->verProc, |
||
| 44 | true |
||
| 45 | ); |
||
| 46 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
| 47 | $ideVinculo = $this->dom->createElement("ideVinculo"); |
||
| 48 | $this->dom->addChild( |
||
| 49 | $ideVinculo, |
||
| 50 | "cpfTrab", |
||
| 51 | $this->std->idevinculo->cpftrab, |
||
| 52 | true |
||
| 53 | ); |
||
| 54 | $this->dom->addChild( |
||
| 55 | $ideVinculo, |
||
| 56 | "nisTrab", |
||
| 57 | $this->std->idevinculo->nistrab, |
||
| 58 | true |
||
| 59 | ); |
||
| 60 | $this->dom->addChild( |
||
| 61 | $ideVinculo, |
||
| 62 | "matricula", |
||
| 63 | $this->std->idevinculo->matricula, |
||
| 64 | true |
||
| 65 | ); |
||
| 66 | $this->node->appendChild($ideVinculo); |
||
| 67 | $infoAvPrevio = $this->dom->createElement("infoAvPrevio"); |
||
| 68 | if (! empty($this->std->infoavprevio->detavprevio)) { |
||
| 69 | $detAvPrevio = $this->dom->createElement("detAvPrevio"); |
||
| 70 | $this->dom->addChild( |
||
| 71 | $detAvPrevio, |
||
| 72 | "dtAvPrv", |
||
| 73 | $this->std->infoavprevio->detavprevio->dtavprv, |
||
| 74 | true |
||
| 75 | ); |
||
| 76 | $this->dom->addChild( |
||
| 77 | $detAvPrevio, |
||
| 78 | "dtPrevDeslig", |
||
| 79 | $this->std->infoavprevio->detavprevio->dtprevdeslig, |
||
| 80 | true |
||
| 81 | ); |
||
| 82 | $this->dom->addChild( |
||
| 83 | $detAvPrevio, |
||
| 84 | "tpAvPrevio", |
||
| 85 | $this->std->infoavprevio->detavprevio->tpavprevio, |
||
| 86 | true |
||
| 87 | ); |
||
| 88 | $this->dom->addChild( |
||
| 89 | $detAvPrevio, |
||
| 90 | "observacao", |
||
| 91 | ! empty($this->std->infoavprevio->detavprevio->observacao) ? |
||
| 92 | $this->std->infoavprevio->detavprevio->observacao : null, |
||
| 93 | false |
||
| 94 | ); |
||
| 95 | $infoAvPrevio->appendChild($detAvPrevio); |
||
| 96 | } |
||
| 97 | if (! empty($this->std->infoavprevio->cancavprevio)) { |
||
| 98 | $cancAvPrevio = $this->dom->createElement("cancAvPrevio"); |
||
| 99 | $this->dom->addChild( |
||
| 100 | $cancAvPrevio, |
||
| 101 | "dtCancAvPrv", |
||
| 102 | $this->std->infoavprevio->cancavprevio->dtcancavprv, |
||
| 103 | true |
||
| 104 | ); |
||
| 105 | $this->dom->addChild( |
||
| 106 | $cancAvPrevio, |
||
| 107 | "observacao", |
||
| 108 | ! empty($this->std->infoavprevio->cancavprevio->observacao) ? |
||
| 109 | $this->std->infoavprevio->cancavprevio->observacao : null, |
||
| 110 | false |
||
| 111 | ); |
||
| 112 | $this->dom->addChild( |
||
| 113 | $cancAvPrevio, |
||
| 114 | "mtvCancAvPrevio", |
||
| 115 | $this->std->infoavprevio->cancavprevio->mtvcancavprevio, |
||
| 116 | true |
||
| 117 | ); |
||
| 118 | $infoAvPrevio->appendChild($cancAvPrevio); |
||
| 119 | } |
||
| 120 | $this->node->appendChild($infoAvPrevio); |
||
| 121 | $this->eSocial->appendChild($this->node); |
||
| 122 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
| 123 | $this->sign(); |
||
| 124 | } |
||
| 125 | |||
| 134 |
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: