Conditions | 13 |
Paths | 30 |
Total Lines | 166 |
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 | //tag deste evento em particular |
||
37 | $info = $this->dom->createElement("infoProcesso"); |
||
38 | |||
39 | //tag comum a todos os modos |
||
40 | $ide = $this->dom->createElement("ideProcesso"); |
||
41 | $this->dom->addChild( |
||
42 | $ide, |
||
43 | "tpProc", |
||
44 | $this->std->tpproc, |
||
45 | true |
||
46 | ); |
||
47 | $this->dom->addChild( |
||
48 | $ide, |
||
49 | "nrProc", |
||
50 | $this->std->nrproc, |
||
51 | true |
||
52 | ); |
||
53 | $this->dom->addChild( |
||
54 | $ide, |
||
55 | "iniValid", |
||
56 | $this->std->inivalid, |
||
57 | true |
||
58 | ); |
||
59 | $this->dom->addChild( |
||
60 | $ide, |
||
61 | "fimValid", |
||
62 | ! empty($this->std->fimvalid) ? $this->std->fimvalid : null, |
||
63 | false |
||
64 | ); |
||
65 | //seleção do modo |
||
66 | if ($this->std->modo == 'INC') { |
||
67 | $node = $this->dom->createElement("inclusao"); |
||
68 | } elseif ($this->std->modo == 'ALT') { |
||
69 | $node = $this->dom->createElement("alteracao"); |
||
70 | } else { |
||
71 | $node = $this->dom->createElement("exclusao"); |
||
72 | } |
||
73 | $node->appendChild($ide); |
||
74 | |||
75 | if ($this->std->modo != 'EXC') { |
||
76 | $dados = $this->dom->createElement("dadosProc"); |
||
77 | $this->dom->addChild( |
||
78 | $dados, |
||
79 | "indAutoria", |
||
80 | ! empty($this->std->dadosproc->indautoria) |
||
81 | ? $this->std->dadosproc->indautoria |
||
82 | : null, |
||
83 | false |
||
84 | ); |
||
85 | $this->dom->addChild( |
||
86 | $dados, |
||
87 | "indMatProc", |
||
88 | $this->std->dadosproc->indmatproc, |
||
89 | true |
||
90 | ); |
||
91 | $this->dom->addChild( |
||
92 | $dados, |
||
93 | "observacao", |
||
94 | !empty($this->std->dadosproc->observacao) ? $this->std->dadosproc->observacao : null, |
||
95 | false |
||
96 | ); |
||
97 | if (! empty($this->std->dadosproc->dadosprocjud)) { |
||
98 | $dadosProcJud = $this->dom->createElement("dadosProcJud"); |
||
99 | $this->dom->addChild( |
||
100 | $dadosProcJud, |
||
101 | "ufVara", |
||
102 | $this->std->dadosproc->dadosprocjud->ufvara, |
||
103 | true |
||
104 | ); |
||
105 | $this->dom->addChild( |
||
106 | $dadosProcJud, |
||
107 | "codMunic", |
||
108 | $this->std->dadosproc->dadosprocjud->codmunic, |
||
109 | true |
||
110 | ); |
||
111 | $this->dom->addChild( |
||
112 | $dadosProcJud, |
||
113 | "idVara", |
||
114 | $this->std->dadosproc->dadosprocjud->idvara, |
||
115 | true |
||
116 | ); |
||
117 | $dados->appendChild($dadosProcJud); |
||
118 | } |
||
119 | if (! empty($this->std->dadosproc->infosusp)) { |
||
120 | foreach ($this->std->dadosproc->infosusp as $susp) { |
||
121 | $infoSusp = $this->dom->createElement("infoSusp"); |
||
122 | $this->dom->addChild( |
||
123 | $infoSusp, |
||
124 | "codSusp", |
||
125 | $susp->codsusp, |
||
126 | true |
||
127 | ); |
||
128 | $this->dom->addChild( |
||
129 | $infoSusp, |
||
130 | "indSusp", |
||
131 | $susp->indsusp, |
||
132 | true |
||
133 | ); |
||
134 | $this->dom->addChild( |
||
135 | $infoSusp, |
||
136 | "dtDecisao", |
||
137 | $susp->dtdecisao, |
||
138 | true |
||
139 | ); |
||
140 | $this->dom->addChild( |
||
141 | $infoSusp, |
||
142 | "indDeposito", |
||
143 | $susp->inddeposito, |
||
144 | true |
||
145 | ); |
||
146 | $dados->appendChild($infoSusp); |
||
147 | } |
||
148 | } |
||
149 | $node->appendChild($dados); |
||
150 | } |
||
151 | if (! empty($this->std->novavalidade) && $this->std->modo == 'ALT') { |
||
152 | $newVal = $this->std->novavalidade; |
||
153 | $novaValidade = $this->dom->createElement("novaValidade"); |
||
154 | $this->dom->addChild( |
||
155 | $ideRubrica, |
||
156 | "iniValid", |
||
157 | $newVal->inivalid, |
||
158 | true |
||
159 | ); |
||
160 | $this->dom->addChild( |
||
161 | $ideRubrica, |
||
162 | "fimValid", |
||
163 | ! empty($newVal->fimvalid) ? $newVal->fimvalid : null, |
||
164 | false |
||
165 | ); |
||
166 | $node->appendChild($novaValidade); |
||
167 | } |
||
168 | |||
169 | $info->appendChild($node); |
||
170 | //finalização do xml |
||
171 | $this->node->appendChild($info); |
||
172 | $this->eSocial->appendChild($this->node); |
||
173 | //$this->xml = $this->dom->saveXML($this->eSocial); |
||
174 | $this->sign(); |
||
175 | } |
||
176 | |||
347 |
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: