Conditions | 7 |
Paths | 16 |
Total Lines | 77 |
Code Lines | 46 |
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 |
||
156 | public function toXML(DOMDocument $document, $accountId) |
||
157 | { |
||
158 | $order = $document->createElement( |
||
159 | 'tns:order' |
||
160 | ); |
||
161 | $order->setAttribute( |
||
162 | 'xmlns:common', |
||
163 | 'http://schema.post.be/shm/deepintegration/v5/common' |
||
164 | ); |
||
165 | $order->setAttribute( |
||
166 | 'xmlns:tns', |
||
167 | 'http://schema.post.be/shm/deepintegration/v5/' |
||
168 | ); |
||
169 | $order->setAttribute( |
||
170 | 'xmlns', |
||
171 | 'http://schema.post.be/shm/deepintegration/v5/national' |
||
172 | ); |
||
173 | $order->setAttribute( |
||
174 | 'xmlns:international', |
||
175 | 'http://schema.post.be/shm/deepintegration/v5/international' |
||
176 | ); |
||
177 | $order->setAttribute( |
||
178 | 'xmlns:xsi', |
||
179 | 'http://www.w3.org/2001/XMLSchema-instance' |
||
180 | ); |
||
181 | $order->setAttribute( |
||
182 | 'xsi:schemaLocation', |
||
183 | 'http://schema.post.be/shm/deepintegration/v5/' |
||
184 | ); |
||
185 | |||
186 | $document->appendChild($order); |
||
187 | |||
188 | $order->appendChild( |
||
189 | $document->createElement( |
||
190 | 'tns:accountId', |
||
191 | (string) $accountId |
||
192 | ) |
||
193 | ); |
||
194 | |||
195 | if ($this->getReference() !== null) { |
||
|
|||
196 | $order->appendChild( |
||
197 | $document->createElement( |
||
198 | 'tns:reference', |
||
199 | $this->getReference() |
||
200 | ) |
||
201 | ); |
||
202 | } |
||
203 | if ($this->getCostCenter() !== null) { |
||
204 | $order->appendChild( |
||
205 | $document->createElement( |
||
206 | 'tns:costCenter', |
||
207 | $this->getCostCenter() |
||
208 | ) |
||
209 | ); |
||
210 | } |
||
211 | |||
212 | $lines = $this->getLines(); |
||
213 | if (!empty($lines)) { |
||
214 | foreach ($lines as $line) { |
||
215 | /** @var $line \Bpost\BpostApiClient\Bpost\Order\Line */ |
||
216 | $order->appendChild( |
||
217 | $line->toXML($document, 'tns') |
||
218 | ); |
||
219 | } |
||
220 | } |
||
221 | |||
222 | $boxes = $this->getBoxes(); |
||
223 | if (!empty($boxes)) { |
||
224 | foreach ($boxes as $box) { |
||
225 | /** @var $box \Bpost\BpostApiClient\Bpost\Order\Box */ |
||
226 | $order->appendChild( |
||
227 | $box->toXML($document, 'tns') |
||
228 | ); |
||
229 | } |
||
230 | } |
||
231 | |||
232 | return $order; |
||
233 | } |
||
271 |