Conditions | 13 |
Paths | 15 |
Total Lines | 134 |
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 | "perApur", |
||
19 | $this->std->perapur, |
||
20 | true |
||
21 | ); |
||
22 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
23 | //tag deste evento em particular |
||
24 | |||
25 | $infofgts = $this->dom->createElement("infoFGTS"); |
||
26 | $this->dom->addChild( |
||
27 | $infofgts, |
||
28 | "nrRecArqBase", |
||
29 | $this->std->infofgts->nrrecarqbase, |
||
30 | true |
||
31 | ); |
||
32 | $this->dom->addChild( |
||
33 | $infofgts, |
||
34 | "indExistInfo", |
||
35 | $this->std->infofgts->indexistinfo, |
||
36 | true |
||
37 | ); |
||
38 | if (!empty($this->std->infofgts->infobasefgts)) { |
||
39 | $infoBaseFGTS = $this->dom->createElement("infoBaseFGTS"); |
||
40 | if (!empty($this->std->infofgts->infobasefgts->baseperapur)) { |
||
41 | foreach ($this->std->infofgts->infobasefgts->baseperapur as $bap) { |
||
42 | $basePerApur = $this->dom->createElement("basePerApur"); |
||
43 | $this->dom->addChild( |
||
44 | $basePerApur, |
||
45 | "tpValor", |
||
46 | $bap->tpvalor, |
||
47 | true |
||
48 | ); |
||
49 | $this->dom->addChild( |
||
50 | $basePerApur, |
||
51 | "baseFGTS", |
||
52 | number_format($bap->basefgts, 2, ".", ""), |
||
53 | true |
||
54 | ); |
||
55 | $infoBaseFGTS->appendChild($basePerApur); |
||
56 | } |
||
57 | } |
||
58 | if (!empty($this->std->infofgts->infobasefgts->infobaseperante)) { |
||
59 | foreach ($this->std->infofgts->infobasefgts->infobaseperante as $ipa) { |
||
60 | $infoBasePerAntE = $this->dom->createElement("infoBasePerAntE"); |
||
61 | $this->dom->addChild( |
||
62 | $infoBasePerAntE, |
||
63 | "perRef", |
||
64 | $ipa->perref, |
||
65 | true |
||
66 | ); |
||
67 | foreach ($ipa->baseperante as $bpae) { |
||
68 | $basePerAntE = $this->dom->createElement("basePerAntE"); |
||
69 | $this->dom->addChild( |
||
70 | $basePerAntE, |
||
71 | "tpValorE", |
||
72 | $bpae->tpvalore, |
||
73 | true |
||
74 | ); |
||
75 | $this->dom->addChild( |
||
76 | $basePerAntE, |
||
77 | "baseFGTSE", |
||
78 | number_format($bpae->basefgtse, 2, ".", ""), |
||
79 | true |
||
80 | ); |
||
81 | $infoBasePerAntE->appendChild($basePerAntE); |
||
82 | } |
||
83 | $infoBaseFGTS->appendChild($infoBasePerAntE); |
||
84 | } |
||
85 | } |
||
86 | $infofgts->appendChild($infoBaseFGTS); |
||
87 | } |
||
88 | if (!empty($this->std->infofgts->infodpsfgts)) { |
||
89 | $infoDpsFGTS = $this->dom->createElement("infoDpsFGTS"); |
||
90 | if (!empty($this->std->infofgts->infodpsfgts->dpsperapur)) { |
||
91 | foreach ($this->std->infofgts->infodpsfgts->dpsperapur as $dpap) { |
||
92 | $dpsPerApur = $this->dom->createElement("dpsPerApur"); |
||
93 | $this->dom->addChild( |
||
94 | $dpsPerApur, |
||
95 | "tpDps", |
||
96 | $dpap->tpdps, |
||
97 | true |
||
98 | ); |
||
99 | $this->dom->addChild( |
||
100 | $dpsPerApur, |
||
101 | "vrFGTS", |
||
102 | number_format($dpap->vrfgts, 2, ".", ""), |
||
103 | true |
||
104 | ); |
||
105 | if (!empty($dpap->infodpsperante)) { |
||
106 | foreach ($dpap->infodpsperante as $ipte) { |
||
107 | $infoDpsPerAntE = $this->dom->createElement("infoDpsPerAntE"); |
||
108 | $this->dom->addChild( |
||
109 | $infoDpsPerAntE, |
||
110 | "perRef", |
||
111 | $ipte->perref, |
||
112 | true |
||
113 | ); |
||
114 | foreach ($ipte->dpsperante as $dpte) { |
||
115 | $dpsPerAntE = $this->dom->createElement("dpsPerAntE"); |
||
116 | $this->dom->addChild( |
||
117 | $dpsPerAntE, |
||
118 | "tpDpsE", |
||
119 | $dpte->tpDpsE, |
||
120 | true |
||
121 | ); |
||
122 | $this->dom->addChild( |
||
123 | $dpsPerAntE, |
||
124 | "vrFGTSE", |
||
125 | $dpte->vrfgtse, |
||
126 | true |
||
127 | ); |
||
128 | $infoDpsPerAntE->appendChild($dpsPerAntE); |
||
129 | } |
||
130 | $dpsPerApur->appendChild($infoDpsPerAntE); |
||
131 | } |
||
132 | } |
||
133 | $infoDpsFGTS->appendChild($dpsPerApur); |
||
134 | } |
||
135 | } |
||
136 | $infofgts->appendChild($infoDpsFGTS); |
||
137 | } |
||
138 | $this->node->appendChild($infofgts); |
||
139 | //finalização do xml |
||
140 | $this->eSocial->appendChild($this->node); |
||
141 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
142 | $this->sign(); |
||
143 | } |
||
144 | |||
153 |
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: