Conditions | 12 |
Paths | 3 |
Total Lines | 194 |
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 | "tpAmb", |
||
25 | $this->tpAmb, |
||
26 | true |
||
27 | ); |
||
28 | $this->dom->addChild( |
||
29 | $ideEvento, |
||
30 | "procEmi", |
||
31 | $this->procEmi, |
||
32 | true |
||
33 | ); |
||
34 | $this->dom->addChild( |
||
35 | $ideEvento, |
||
36 | "verProc", |
||
37 | $this->verProc, |
||
38 | true |
||
39 | ); |
||
40 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
41 | $ideVinculo = $this->dom->createElement("ideVinculo"); |
||
42 | $this->dom->addChild( |
||
43 | $ideVinculo, |
||
44 | "cpfTrab", |
||
45 | $this->std->idevinculo->cpftrab, |
||
46 | true |
||
47 | ); |
||
48 | $this->dom->addChild( |
||
49 | $ideVinculo, |
||
50 | "nisTrab", |
||
51 | $this->std->idevinculo->nistrab, |
||
52 | true |
||
53 | ); |
||
54 | $this->dom->addChild( |
||
55 | $ideVinculo, |
||
56 | "matricula", |
||
57 | !empty($this->std->idevinculo->matricula) ? $this->std->idevinculo->matricula : null, |
||
58 | false |
||
59 | ); |
||
60 | $this->node->appendChild($ideVinculo); |
||
61 | |||
62 | if ($this->layoutStr !== 'v02_05_00') { |
||
63 | $aso = $this->dom->createElement("aso"); |
||
64 | $this->dom->addChild( |
||
65 | $aso, |
||
66 | "dtAso", |
||
67 | $this->std->aso->dtaso, |
||
68 | true |
||
69 | ); |
||
70 | $this->dom->addChild( |
||
71 | $aso, |
||
72 | "resAso", |
||
73 | $this->std->aso->resaso, |
||
74 | true |
||
75 | ); |
||
76 | if (isset($this->std->aso->exame)) { |
||
77 | foreach ($this->std->aso->exame as $exa) { |
||
78 | $exame = $this->dom->createElement("exame"); |
||
79 | $this->dom->addChild( |
||
80 | $exame, |
||
81 | "dtExm", |
||
82 | $exa->dtexm, |
||
83 | true |
||
84 | ); |
||
85 | $this->dom->addChild( |
||
86 | $exame, |
||
87 | "procRealizado", |
||
88 | !empty($exa->procrealizado) ? $exa->procrealizado : null, |
||
89 | false |
||
90 | ); |
||
91 | $this->dom->addChild( |
||
92 | $exame, |
||
93 | "obsProc", |
||
94 | !empty($exa->obsproc) ? $exa->obsproc : null, |
||
95 | false |
||
96 | ); |
||
97 | $this->dom->addChild( |
||
98 | $exame, |
||
99 | "interprExm", |
||
100 | $exa->interprexm, |
||
101 | true |
||
102 | ); |
||
103 | $this->dom->addChild( |
||
104 | $exame, |
||
105 | "ordExame", |
||
106 | $exa->ordexame, |
||
107 | true |
||
108 | ); |
||
109 | $this->dom->addChild( |
||
110 | $exame, |
||
111 | "dtIniMonit", |
||
112 | $exa->dtinimonit, |
||
113 | true |
||
114 | ); |
||
115 | $this->dom->addChild( |
||
116 | $exame, |
||
117 | "dtFimMonit", |
||
118 | !empty($exa->dtfimmonit) ? $exa->dtfimmonit : null, |
||
119 | false |
||
120 | ); |
||
121 | $this->dom->addChild( |
||
122 | $exame, |
||
123 | "indResult", |
||
124 | !empty($exa->indresult) ? $exa->indresult : null, |
||
125 | false |
||
126 | ); |
||
127 | $respMonit = $this->dom->createElement("respMonit"); |
||
128 | $resm = $exa->respmonit; |
||
129 | $this->dom->addChild( |
||
130 | $respMonit, |
||
131 | "nisResp", |
||
132 | $resm->nisresp, |
||
133 | true |
||
134 | ); |
||
135 | $this->dom->addChild( |
||
136 | $respMonit, |
||
137 | "nrConsClasse", |
||
138 | $resm->nrconsclasse, |
||
139 | true |
||
140 | ); |
||
141 | $this->dom->addChild( |
||
142 | $respMonit, |
||
143 | "ufConsClasse", |
||
144 | !empty($resm->ufconsclasse) ? $resm->ufconsclasse : null, |
||
145 | false |
||
146 | ); |
||
147 | $exame->appendChild($respMonit); |
||
148 | $aso->appendChild($exame); |
||
149 | } |
||
150 | } |
||
151 | $ideServSaude = $this->dom->createElement("ideServSaude"); |
||
152 | $sers = $this->std->aso->ideservsaude; |
||
153 | $this->dom->addChild( |
||
154 | $ideServSaude, |
||
155 | "codCNES", |
||
156 | !empty($sers->codcnes) ? $sers->codcnes : null, |
||
157 | false |
||
158 | ); |
||
159 | $this->dom->addChild( |
||
160 | $ideServSaude, |
||
161 | "frmCtt", |
||
162 | $sers->frmctt, |
||
163 | true |
||
164 | ); |
||
165 | $this->dom->addChild( |
||
166 | $ideServSaude, |
||
167 | "email", |
||
168 | !empty($sers->email) ? $sers->email : null, |
||
169 | false |
||
170 | ); |
||
171 | $medico = $this->dom->createElement("medico"); |
||
172 | $med = $sers->medico; |
||
173 | $this->dom->addChild( |
||
174 | $medico, |
||
175 | "nmMed", |
||
176 | $med->nmmed, |
||
177 | true |
||
178 | ); |
||
179 | $crm = $this->dom->createElement("crm"); |
||
180 | $this->dom->addChild( |
||
181 | $crm, |
||
182 | "nrCRM", |
||
183 | $med->nrcrm, |
||
184 | true |
||
185 | ); |
||
186 | $this->dom->addChild( |
||
187 | $crm, |
||
188 | "ufCRM", |
||
189 | $med->ufcrm, |
||
190 | true |
||
191 | ); |
||
192 | $medico->appendChild($crm); |
||
193 | $ideServSaude->appendChild($medico); |
||
194 | $aso->appendChild($ideServSaude); |
||
195 | $this->node->appendChild($aso); |
||
196 | } else { |
||
197 | $this->v020500(); |
||
198 | } |
||
199 | //finalização do xml |
||
200 | $this->eSocial->appendChild($this->node); |
||
201 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
202 | $this->sign(); |
||
203 | } |
||
204 | |||
494 |
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: