Conditions | 24 |
Paths | 2 |
Total Lines | 179 |
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 |
||
33 | protected function toNode() |
||
34 | { |
||
35 | $ideDeclarante = $this->node->getElementsByTagName('ideDeclarante')->item(0); |
||
36 | //o idEvento pode variar de evento para evento |
||
37 | //então cada factory individualmente terá de construir o seu |
||
38 | $ideEvento = $this->dom->createElement("ideEvento"); |
||
39 | $this->dom->addChild( |
||
40 | $ideEvento, |
||
41 | "ideEventoRERCT", |
||
42 | $this->std->ideeventorerct, |
||
43 | true |
||
44 | ); |
||
45 | $this->dom->addChild( |
||
46 | $ideEvento, |
||
47 | "indRetificacao", |
||
48 | $this->std->indretificacao, |
||
49 | true |
||
50 | ); |
||
51 | $this->dom->addChild( |
||
52 | $ideEvento, |
||
53 | "nrRecibo", |
||
54 | isset($this->std->nrrecibo) ? $this->std->nrrecibo : null, |
||
55 | false |
||
56 | ); |
||
57 | $this->dom->addChild( |
||
58 | $ideEvento, |
||
59 | "tpAmb", |
||
60 | (string) $this->tpAmb, |
||
61 | true |
||
62 | ); |
||
63 | $this->dom->addChild( |
||
64 | $ideEvento, |
||
65 | "aplicEmi", |
||
66 | '1', |
||
67 | true |
||
68 | ); |
||
69 | $this->dom->addChild( |
||
70 | $ideEvento, |
||
71 | "verAplic", |
||
72 | $this->verAplic, |
||
73 | true |
||
74 | ); |
||
75 | $this->node->insertBefore($ideEvento, $ideDeclarante); |
||
76 | |||
77 | $ideDeclarado = $this->dom->createElement("ideDeclarado"); |
||
78 | $cpfCnpjDeclarado = $this->dom->createElement("cpfCnpjDeclarado"); |
||
79 | $this->dom->addChild( |
||
80 | $cpfCnpjDeclarado, |
||
81 | "tpInscr", |
||
82 | $this->std->idedeclarado->tpinscr, |
||
83 | true |
||
84 | ); |
||
85 | $this->dom->addChild( |
||
86 | $cpfCnpjDeclarado, |
||
87 | "nrInscr", |
||
88 | $this->std->idedeclarado->nrinscr, |
||
89 | true |
||
90 | ); |
||
91 | $ideDeclarado->appendChild($cpfCnpjDeclarado); |
||
92 | $this->node->appendChild($ideDeclarado); |
||
93 | |||
94 | if (!empty($this->std->rerct)) { |
||
95 | foreach ($this->std->rerct as $r) { |
||
96 | $RERCT = $this->dom->createElement("RERCT"); |
||
97 | $this->dom->addChild( |
||
98 | $RERCT, |
||
99 | "nomeBancoOrigem", |
||
100 | !empty($r->nomebancoorigem) ? $r->nomebancoorigem : null, |
||
101 | false |
||
102 | ); |
||
103 | $this->dom->addChild( |
||
104 | $RERCT, |
||
105 | "paisOrigem", |
||
106 | !empty($r->paisorigem) ? $r->paisorigem : null, |
||
107 | false |
||
108 | ); |
||
109 | $this->dom->addChild( |
||
110 | $RERCT, |
||
111 | "BICBancoOrigem", |
||
112 | !empty($r->bicbancoorigem) ? $r->bicbancoorigem : null, |
||
113 | false |
||
114 | ); |
||
115 | if (!empty($r->infocontaexterior)) { |
||
116 | foreach ($r->infocontaexterior as $ce) { |
||
117 | $infoContaExterior = $this->dom->createElement("infoContaExterior"); |
||
118 | if (!empty($ce->titular)) { |
||
119 | foreach ($ce->titular as $t) { |
||
120 | $titular = $this->dom->createElement("titular"); |
||
121 | $this->dom->addChild( |
||
122 | $titular, |
||
123 | "nomeTitular", |
||
124 | !empty($t->nometitular) ? $t->nometitular : null, |
||
125 | false |
||
126 | ); |
||
127 | if (!empty($t->tpinsc) && !empty($t->nrinsc)) { |
||
128 | $cpfCnpjTitular = $this->dom->createElement("cpfCnpjTitular"); |
||
129 | $this->dom->addChild( |
||
130 | $cpfCnpjTitular, |
||
131 | "tpInscr", |
||
132 | $t->tpinscr, |
||
133 | true |
||
134 | ); |
||
135 | $this->dom->addChild( |
||
136 | $cpfCnpjTitular, |
||
137 | "nrInsc", |
||
138 | $t->nrinscr, |
||
139 | true |
||
140 | ); |
||
141 | $titular->appendChild($cpfCnpjTitular); |
||
142 | } |
||
143 | $this->dom->addChild( |
||
144 | $titular, |
||
145 | "NIFTitular", |
||
146 | !empty($t->niftitular) ? $t->niftitular : null, |
||
147 | false |
||
148 | ); |
||
149 | $infoContaExterior->appendChild($titular); |
||
150 | } |
||
151 | } |
||
152 | if (!empty($ce->beneficiariofinal)) { |
||
153 | foreach ($ce->beneficiariofinal as $t) { |
||
154 | $beneficiariofinal = $this->dom->createElement("beneficiarioFinal"); |
||
155 | $this->dom->addChild( |
||
156 | $beneficiariofinal, |
||
157 | "nomeBeneficiarioFinal", |
||
158 | !empty($t->nomebeneficiariofinal) ? $t->nomebeneficiariofinal : null, |
||
159 | false |
||
160 | ); |
||
161 | $this->dom->addChild( |
||
162 | $beneficiariofinal, |
||
163 | "cpfBeneficiarioFinal", |
||
164 | !empty($t->cpfbeneficiariofinal) ? $t->cpfbeneficiariofinal : null, |
||
165 | false |
||
166 | ); |
||
167 | $this->dom->addChild( |
||
168 | $beneficiariofinal, |
||
169 | "NIFBeneficiarioFinal", |
||
170 | !empty($t->nifbeneficiariofinal) ? $t->nifbeneficiariofinal : null, |
||
171 | false |
||
172 | ); |
||
173 | $infoContaExterior->appendChild($beneficiariofinal); |
||
174 | } |
||
175 | } |
||
176 | |||
177 | $this->dom->addChild( |
||
178 | $infoContaExterior, |
||
179 | "tpContaExterior", |
||
180 | !empty($ce->tpcontaexterior) ? $ce->tpcontaexterior : null, |
||
181 | false |
||
182 | ); |
||
183 | $this->dom->addChild( |
||
184 | $infoContaExterior, |
||
185 | "nrContaExterior", |
||
186 | !empty($ce->nrcontaexterior) ? $ce->nrcontaexterior : null, |
||
187 | false |
||
188 | ); |
||
189 | $this->dom->addChild( |
||
190 | $infoContaExterior, |
||
191 | "vlrUltDia", |
||
192 | !empty($ce->vlrultdia) ? number_format($ce->vlrultdia, 2, ",", "") : null, |
||
193 | false |
||
194 | ); |
||
195 | $this->dom->addChild( |
||
196 | $infoContaExterior, |
||
197 | "moeda", |
||
198 | !empty($ce->moeda) ? $ce->moeda : null, |
||
199 | false |
||
200 | ); |
||
201 | $RERCT->appendChild($infoContaExterior); |
||
202 | } |
||
203 | } |
||
204 | $this->node->appendChild($RERCT); |
||
205 | } |
||
206 | } |
||
207 | //finalização do xml |
||
208 | $this->eFinanceira->appendChild($this->node); |
||
209 | //$this->xml = $this->dom->saveXML($this->eFinanceira); |
||
210 | $this->sign($this->evtTag); |
||
211 | } |
||
212 | } |
||
213 |