Conditions | 14 |
Paths | 40 |
Total Lines | 186 |
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 | "tpAmb", |
||
19 | $this->tpAmb, |
||
20 | true |
||
21 | ); |
||
22 | $this->dom->addChild( |
||
23 | $ideEvento, |
||
24 | "procEmi", |
||
25 | $this->procEmi, |
||
26 | true |
||
27 | ); |
||
28 | $this->dom->addChild( |
||
29 | $ideEvento, |
||
30 | "verProc", |
||
31 | $this->verProc, |
||
32 | true |
||
33 | ); |
||
34 | $this->node->insertBefore($ideEvento, $ideEmpregador); |
||
35 | |||
36 | $ide = $this->dom->createElement("ideLotacao"); |
||
37 | $this->dom->addChild( |
||
38 | $ide, |
||
39 | "codLotacao", |
||
40 | $this->std->codlotacao, |
||
41 | true |
||
42 | ); |
||
43 | $this->dom->addChild( |
||
44 | $ide, |
||
45 | "iniValid", |
||
46 | $this->std->inivalid, |
||
47 | true |
||
48 | ); |
||
49 | $this->dom->addChild( |
||
50 | $ide, |
||
51 | "fimValid", |
||
52 | ! empty($this->std->fimvalid) ? $this->std->fimvalid : null, |
||
53 | false |
||
54 | ); |
||
55 | |||
56 | |||
57 | if (!empty($this->std->dadoslotacao)) { |
||
58 | $da = $this->std->dadoslotacao; |
||
59 | $dados = $this->dom->createElement("dadosLotacao"); |
||
60 | $this->dom->addChild( |
||
61 | $dados, |
||
62 | "tpLotacao", |
||
63 | $da->tplotacao, |
||
64 | true |
||
65 | ); |
||
66 | $this->dom->addChild( |
||
67 | $dados, |
||
68 | "tpInsc", |
||
69 | !empty($da->tpinsc) ? $da->tpinsc : null, |
||
70 | false |
||
71 | ); |
||
72 | $this->dom->addChild( |
||
73 | $dados, |
||
74 | "nrInsc", |
||
75 | !empty($da->nrinsc) ? $da->nrinsc : null, |
||
76 | false |
||
77 | ); |
||
78 | $fpasLotacao = $this->dom->createElement("fpasLotacao"); |
||
79 | $this->dom->addChild( |
||
80 | $fpasLotacao, |
||
81 | "fpas", |
||
82 | $da->fpas, |
||
83 | true |
||
84 | ); |
||
85 | $this->dom->addChild( |
||
86 | $fpasLotacao, |
||
87 | "codTercs", |
||
88 | $da->codtercs, |
||
89 | true |
||
90 | ); |
||
91 | $this->dom->addChild( |
||
92 | $fpasLotacao, |
||
93 | "codTercsSusp", |
||
94 | !empty($da->codtercssusp) ? $da->codtercssusp : null, |
||
95 | false |
||
96 | ); |
||
97 | |||
98 | if (!empty($da->procjudterceiro)) { |
||
99 | $procjud = $this->dom->createElement("infoProcJudTerceiros"); |
||
100 | foreach ($da->procjudterceiro as $proc) { |
||
101 | $pjt = $this->dom->createElement("procJudTerceiro"); |
||
102 | $this->dom->addChild( |
||
103 | $pjt, |
||
104 | "codTerc", |
||
105 | $proc->codterc, |
||
106 | true |
||
107 | ); |
||
108 | $this->dom->addChild( |
||
109 | $pjt, |
||
110 | "nrProcJud", |
||
111 | $proc->nrprocjud, |
||
112 | true |
||
113 | ); |
||
114 | $this->dom->addChild( |
||
115 | $pjt, |
||
116 | "codSusp", |
||
117 | $proc->codsusp, |
||
118 | true |
||
119 | ); |
||
120 | $procjud->appendChild($pjt); |
||
121 | } |
||
122 | $fpasLotacao->appendChild($procjud); |
||
123 | } |
||
124 | $dados->appendChild($fpasLotacao); |
||
125 | |||
126 | if (!empty($da->infoemprparcial)) { |
||
127 | $parcial = $this->dom->createElement("infoEmprParcial"); |
||
128 | $this->dom->addChild( |
||
129 | $parcial, |
||
130 | "tpInscContrat", |
||
131 | $da->infoemprparcial->tpinsccontrat, |
||
132 | true |
||
133 | ); |
||
134 | $this->dom->addChild( |
||
135 | $parcial, |
||
136 | "nrInscContrat", |
||
137 | $da->infoemprparcial->nrinsccontrat, |
||
138 | true |
||
139 | ); |
||
140 | $this->dom->addChild( |
||
141 | $parcial, |
||
142 | "tpInscProp", |
||
143 | $da->infoemprparcial->tpinscprop, |
||
144 | true |
||
145 | ); |
||
146 | $this->dom->addChild( |
||
147 | $parcial, |
||
148 | "nrInscProp", |
||
149 | $da->infoemprparcial->nrinscprop, |
||
150 | true |
||
151 | ); |
||
152 | $dados->appendChild($parcial); |
||
153 | } |
||
154 | } |
||
155 | |||
156 | if (!empty($this->std->novavalidade)) { |
||
157 | $nova = $this->dom->createElement("novaValidade"); |
||
158 | $this->dom->addChild( |
||
159 | $nova, |
||
160 | "iniValid", |
||
161 | $this->std->novavalidade->inivalid, |
||
162 | true |
||
163 | ); |
||
164 | $this->dom->addChild( |
||
165 | $nova, |
||
166 | "fimValid", |
||
167 | ! empty($this->std->novavalidade->fimvalid) |
||
168 | ? $this->std->novavalidade->fimvalid |
||
169 | : null, |
||
170 | false |
||
171 | ); |
||
172 | } |
||
173 | |||
174 | $info = $this->dom->createElement("infoLotacao"); |
||
175 | //seleção do modo |
||
176 | if ($this->std->modo == 'INC') { |
||
177 | $node = $this->dom->createElement("inclusao"); |
||
178 | $node->appendChild($ide); |
||
179 | $node->appendChild($dados); |
||
180 | } elseif ($this->std->modo == 'ALT') { |
||
181 | $node = $this->dom->createElement("alteracao"); |
||
182 | $node->appendChild($ide); |
||
183 | $node->appendChild($dados); |
||
184 | isset($nova) ? $node->appendChild($nova) : null; |
||
185 | } else { |
||
186 | $node = $this->dom->createElement("exclusao"); |
||
187 | $node->appendChild($ide); |
||
188 | } |
||
189 | |||
190 | $info->appendChild($node); |
||
191 | $this->node->appendChild($info); |
||
192 | $this->eSocial->appendChild($this->node); |
||
193 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
194 | $this->sign(); |
||
195 | } |
||
196 | |||
387 |
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: