Conditions | 35 |
Paths | > 20000 |
Total Lines | 220 |
Code Lines | 153 |
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 |
||
247 | protected function getForm() |
||
248 | { |
||
249 | $data['breadcrumbs'] = array(); |
||
250 | |||
251 | $data['breadcrumbs'][] = array( |
||
252 | 'text' => $this->language->get('text_home'), |
||
253 | 'href' => $this->url->link('common/home') |
||
254 | ); |
||
255 | |||
256 | $data['breadcrumbs'][] = array( |
||
257 | 'text' => $this->language->get('text_account'), |
||
258 | 'href' => $this->url->link('account/account', '', true) |
||
259 | ); |
||
260 | |||
261 | $data['breadcrumbs'][] = array( |
||
262 | 'text' => $this->language->get('heading_title'), |
||
263 | 'href' => $this->url->link('account/address', '', true) |
||
264 | ); |
||
265 | |||
266 | if (!isset($this->request->get['address_id'])) { |
||
267 | $data['breadcrumbs'][] = array( |
||
268 | 'text' => $this->language->get('text_edit_address'), |
||
269 | 'href' => $this->url->link('account/address/add', '', true) |
||
270 | ); |
||
271 | } else { |
||
272 | $data['breadcrumbs'][] = array( |
||
273 | 'text' => $this->language->get('text_edit_address'), |
||
274 | 'href' => $this->url->link('account/address/edit', 'address_id=' . $this->request->get['address_id'], true) |
||
275 | ); |
||
276 | } |
||
277 | |||
278 | $data['heading_title'] = $this->language->get('heading_title'); |
||
279 | |||
280 | $data['text_edit_address'] = $this->language->get('text_edit_address'); |
||
281 | $data['text_yes'] = $this->language->get('text_yes'); |
||
282 | $data['text_no'] = $this->language->get('text_no'); |
||
283 | $data['text_select'] = $this->language->get('text_select'); |
||
284 | $data['text_none'] = $this->language->get('text_none'); |
||
285 | $data['text_loading'] = $this->language->get('text_loading'); |
||
286 | |||
287 | $data['entry_firstname'] = $this->language->get('entry_firstname'); |
||
288 | $data['entry_lastname'] = $this->language->get('entry_lastname'); |
||
289 | $data['entry_company'] = $this->language->get('entry_company'); |
||
290 | $data['entry_address_1'] = $this->language->get('entry_address_1'); |
||
291 | $data['entry_address_2'] = $this->language->get('entry_address_2'); |
||
292 | $data['entry_postcode'] = $this->language->get('entry_postcode'); |
||
293 | $data['entry_city'] = $this->language->get('entry_city'); |
||
294 | $data['entry_country'] = $this->language->get('entry_country'); |
||
295 | $data['entry_zone'] = $this->language->get('entry_zone'); |
||
296 | $data['entry_default'] = $this->language->get('entry_default'); |
||
297 | |||
298 | $data['button_continue'] = $this->language->get('button_continue'); |
||
299 | $data['button_back'] = $this->language->get('button_back'); |
||
300 | $data['button_upload'] = $this->language->get('button_upload'); |
||
301 | |||
302 | if (isset($this->error['firstname'])) { |
||
303 | $data['error_firstname'] = $this->error['firstname']; |
||
304 | } else { |
||
305 | $data['error_firstname'] = ''; |
||
306 | } |
||
307 | |||
308 | if (isset($this->error['lastname'])) { |
||
309 | $data['error_lastname'] = $this->error['lastname']; |
||
310 | } else { |
||
311 | $data['error_lastname'] = ''; |
||
312 | } |
||
313 | |||
314 | if (isset($this->error['address_1'])) { |
||
315 | $data['error_address_1'] = $this->error['address_1']; |
||
316 | } else { |
||
317 | $data['error_address_1'] = ''; |
||
318 | } |
||
319 | |||
320 | if (isset($this->error['city'])) { |
||
321 | $data['error_city'] = $this->error['city']; |
||
322 | } else { |
||
323 | $data['error_city'] = ''; |
||
324 | } |
||
325 | |||
326 | if (isset($this->error['postcode'])) { |
||
327 | $data['error_postcode'] = $this->error['postcode']; |
||
328 | } else { |
||
329 | $data['error_postcode'] = ''; |
||
330 | } |
||
331 | |||
332 | if (isset($this->error['country'])) { |
||
333 | $data['error_country'] = $this->error['country']; |
||
334 | } else { |
||
335 | $data['error_country'] = ''; |
||
336 | } |
||
337 | |||
338 | if (isset($this->error['zone'])) { |
||
339 | $data['error_zone'] = $this->error['zone']; |
||
340 | } else { |
||
341 | $data['error_zone'] = ''; |
||
342 | } |
||
343 | |||
344 | if (isset($this->error['custom_field'])) { |
||
345 | $data['error_custom_field'] = $this->error['custom_field']; |
||
346 | } else { |
||
347 | $data['error_custom_field'] = array(); |
||
348 | } |
||
349 | |||
350 | if (!isset($this->request->get['address_id'])) { |
||
351 | $data['action'] = $this->url->link('account/address/add', '', true); |
||
352 | } else { |
||
353 | $data['action'] = $this->url->link('account/address/edit', 'address_id=' . $this->request->get['address_id'], true); |
||
354 | } |
||
355 | |||
356 | if (isset($this->request->get['address_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { |
||
357 | $address_info = $this->model_account_address->getAddress($this->request->get['address_id']); |
||
358 | } |
||
359 | |||
360 | if (isset($this->request->post['firstname'])) { |
||
361 | $data['firstname'] = $this->request->post['firstname']; |
||
362 | } elseif (!empty($address_info)) { |
||
363 | $data['firstname'] = $address_info['firstname']; |
||
364 | } else { |
||
365 | $data['firstname'] = ''; |
||
366 | } |
||
367 | |||
368 | if (isset($this->request->post['lastname'])) { |
||
369 | $data['lastname'] = $this->request->post['lastname']; |
||
370 | } elseif (!empty($address_info)) { |
||
371 | $data['lastname'] = $address_info['lastname']; |
||
372 | } else { |
||
373 | $data['lastname'] = ''; |
||
374 | } |
||
375 | |||
376 | if (isset($this->request->post['company'])) { |
||
377 | $data['company'] = $this->request->post['company']; |
||
378 | } elseif (!empty($address_info)) { |
||
379 | $data['company'] = $address_info['company']; |
||
380 | } else { |
||
381 | $data['company'] = ''; |
||
382 | } |
||
383 | |||
384 | if (isset($this->request->post['address_1'])) { |
||
385 | $data['address_1'] = $this->request->post['address_1']; |
||
386 | } elseif (!empty($address_info)) { |
||
387 | $data['address_1'] = $address_info['address_1']; |
||
388 | } else { |
||
389 | $data['address_1'] = ''; |
||
390 | } |
||
391 | |||
392 | if (isset($this->request->post['address_2'])) { |
||
393 | $data['address_2'] = $this->request->post['address_2']; |
||
394 | } elseif (!empty($address_info)) { |
||
395 | $data['address_2'] = $address_info['address_2']; |
||
396 | } else { |
||
397 | $data['address_2'] = ''; |
||
398 | } |
||
399 | |||
400 | if (isset($this->request->post['postcode'])) { |
||
401 | $data['postcode'] = $this->request->post['postcode']; |
||
402 | } elseif (!empty($address_info)) { |
||
403 | $data['postcode'] = $address_info['postcode']; |
||
404 | } else { |
||
405 | $data['postcode'] = ''; |
||
406 | } |
||
407 | |||
408 | if (isset($this->request->post['city'])) { |
||
409 | $data['city'] = $this->request->post['city']; |
||
410 | } elseif (!empty($address_info)) { |
||
411 | $data['city'] = $address_info['city']; |
||
412 | } else { |
||
413 | $data['city'] = ''; |
||
414 | } |
||
415 | |||
416 | if (isset($this->request->post['country_id'])) { |
||
417 | $data['country_id'] = (int)$this->request->post['country_id']; |
||
418 | } elseif (!empty($address_info)) { |
||
419 | $data['country_id'] = $address_info['country_id']; |
||
420 | } else { |
||
421 | $data['country_id'] = $this->config->get('config_country_id'); |
||
422 | } |
||
423 | |||
424 | if (isset($this->request->post['zone_id'])) { |
||
425 | $data['zone_id'] = (int)$this->request->post['zone_id']; |
||
426 | } elseif (!empty($address_info)) { |
||
427 | $data['zone_id'] = $address_info['zone_id']; |
||
428 | } else { |
||
429 | $data['zone_id'] = ''; |
||
430 | } |
||
431 | |||
432 | $this->load->model('localisation/country'); |
||
433 | |||
434 | $data['countries'] = $this->model_localisation_country->getCountries(); |
||
435 | |||
436 | // Custom fields |
||
437 | $this->load->model('account/custom_field'); |
||
438 | |||
439 | $data['custom_fields'] = $this->model_account_custom_field->getCustomFields($this->config->get('config_customer_group_id')); |
||
440 | |||
441 | if (isset($this->request->post['custom_field'])) { |
||
442 | $data['address_custom_field'] = $this->request->post['custom_field']; |
||
443 | } elseif (isset($address_info)) { |
||
444 | $data['address_custom_field'] = $address_info['custom_field']; |
||
445 | } else { |
||
446 | $data['address_custom_field'] = array(); |
||
447 | } |
||
448 | |||
449 | if (isset($this->request->post['default'])) { |
||
450 | $data['default'] = $this->request->post['default']; |
||
451 | } elseif (isset($this->request->get['address_id'])) { |
||
452 | $data['default'] = $this->customer->getAddressId() == $this->request->get['address_id']; |
||
453 | } else { |
||
454 | $data['default'] = false; |
||
455 | } |
||
456 | |||
457 | $data['back'] = $this->url->link('account/address', '', true); |
||
458 | |||
459 | $data['column'] = $this->load->controller('common/column'); |
||
460 | $data['content_top'] = $this->load->controller('common/content_top'); |
||
461 | $data['content_bottom'] = $this->load->controller('common/content_bottom'); |
||
462 | $data['footer'] = $this->load->controller('common/footer'); |
||
463 | $data['header'] = $this->load->controller('common/header'); |
||
464 | |||
465 | |||
466 | $this->response->setOutput($this->load->view('account/address_form', $data)); |
||
467 | } |
||
532 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.