Conditions | 32 |
Paths | > 20000 |
Total Lines | 171 |
Code Lines | 116 |
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 |
||
289 | protected function getForm() |
||
290 | { |
||
291 | $data['heading_title'] = $this->language->get('heading_title'); |
||
292 | |||
293 | $data['text_form'] = !isset($this->request->get['location_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
||
294 | $data['text_select'] = $this->language->get('text_select'); |
||
295 | $data['text_none'] = $this->language->get('text_none'); |
||
296 | $data['text_default'] = $this->language->get('text_default'); |
||
297 | $data['text_geocode'] = $this->language->get('text_geocode'); |
||
298 | |||
299 | $data['entry_name'] = $this->language->get('entry_name'); |
||
300 | $data['entry_address'] = $this->language->get('entry_address'); |
||
301 | $data['entry_geocode'] = $this->language->get('entry_geocode'); |
||
302 | $data['entry_telephone'] = $this->language->get('entry_telephone'); |
||
303 | $data['entry_fax'] = $this->language->get('entry_fax'); |
||
304 | $data['entry_image'] = $this->language->get('entry_image'); |
||
305 | $data['entry_open'] = $this->language->get('entry_open'); |
||
306 | $data['entry_comment'] = $this->language->get('entry_comment'); |
||
307 | |||
308 | $data['help_geocode'] = $this->language->get('help_geocode'); |
||
309 | $data['help_open'] = $this->language->get('help_open'); |
||
310 | $data['help_comment'] = $this->language->get('help_comment'); |
||
311 | |||
312 | $data['button_save'] = $this->language->get('button_save'); |
||
313 | $data['button_cancel'] = $this->language->get('button_cancel'); |
||
314 | |||
315 | if (isset($this->error['warning'])) { |
||
316 | $data['error_warning'] = $this->error['warning']; |
||
317 | } else { |
||
318 | $data['error_warning'] = ''; |
||
319 | } |
||
320 | |||
321 | if (isset($this->error['name'])) { |
||
322 | $data['error_name'] = $this->error['name']; |
||
323 | } else { |
||
324 | $data['error_name'] = ''; |
||
325 | } |
||
326 | |||
327 | if (isset($this->error['address'])) { |
||
328 | $data['error_address'] = $this->error['address']; |
||
329 | } else { |
||
330 | $data['error_address'] = ''; |
||
331 | } |
||
332 | |||
333 | if (isset($this->error['telephone'])) { |
||
334 | $data['error_telephone'] = $this->error['telephone']; |
||
335 | } else { |
||
336 | $data['error_telephone'] = ''; |
||
337 | } |
||
338 | |||
339 | $url = ''; |
||
340 | |||
341 | if (isset($this->request->get['sort'])) { |
||
342 | $url .= '&sort=' . $this->request->get['sort']; |
||
343 | } |
||
344 | |||
345 | if (isset($this->request->get['order'])) { |
||
346 | $url .= '&order=' . $this->request->get['order']; |
||
347 | } |
||
348 | |||
349 | if (isset($this->request->get['page'])) { |
||
350 | $url .= '&page=' . $this->request->get['page']; |
||
351 | } |
||
352 | |||
353 | $data['breadcrumbs'] = array(); |
||
354 | |||
355 | $data['breadcrumbs'][] = array( |
||
356 | 'text' => $this->language->get('text_home'), |
||
357 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
358 | ); |
||
359 | |||
360 | $data['breadcrumbs'][] = array( |
||
361 | 'text' => $this->language->get('heading_title'), |
||
362 | 'href' => $this->url->link('localisation/location', 'token=' . $this->session->data['token'] . $url, true) |
||
363 | ); |
||
364 | |||
365 | if (!isset($this->request->get['location_id'])) { |
||
366 | $data['action'] = $this->url->link('localisation/location/add', 'token=' . $this->session->data['token'] . $url, true); |
||
367 | } else { |
||
368 | $data['action'] = $this->url->link('localisation/location/edit', 'token=' . $this->session->data['token'] . '&location_id=' . $this->request->get['location_id'] . $url, true); |
||
369 | } |
||
370 | |||
371 | $data['cancel'] = $this->url->link('localisation/location', 'token=' . $this->session->data['token'] . $url, true); |
||
372 | |||
373 | if (isset($this->request->get['location_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { |
||
374 | $location_info = $this->model_localisation_location->getLocation($this->request->get['location_id']); |
||
375 | } |
||
376 | |||
377 | $data['token'] = $this->session->data['token']; |
||
378 | |||
379 | if (isset($this->request->post['name'])) { |
||
380 | $data['name'] = $this->request->post['name']; |
||
381 | } elseif (!empty($location_info)) { |
||
382 | $data['name'] = $location_info['name']; |
||
383 | } else { |
||
384 | $data['name'] = ''; |
||
385 | } |
||
386 | |||
387 | if (isset($this->request->post['address'])) { |
||
388 | $data['address'] = $this->request->post['address']; |
||
389 | } elseif (!empty($location_info)) { |
||
390 | $data['address'] = $location_info['address']; |
||
391 | } else { |
||
392 | $data['address'] = ''; |
||
393 | } |
||
394 | |||
395 | if (isset($this->request->post['geocode'])) { |
||
396 | $data['geocode'] = $this->request->post['geocode']; |
||
397 | } elseif (!empty($location_info)) { |
||
398 | $data['geocode'] = $location_info['geocode']; |
||
399 | } else { |
||
400 | $data['geocode'] = ''; |
||
401 | } |
||
402 | |||
403 | if (isset($this->request->post['telephone'])) { |
||
404 | $data['telephone'] = $this->request->post['telephone']; |
||
405 | } elseif (!empty($location_info)) { |
||
406 | $data['telephone'] = $location_info['telephone']; |
||
407 | } else { |
||
408 | $data['telephone'] = ''; |
||
409 | } |
||
410 | |||
411 | if (isset($this->request->post['fax'])) { |
||
412 | $data['fax'] = $this->request->post['fax']; |
||
413 | } elseif (!empty($location_info)) { |
||
414 | $data['fax'] = $location_info['fax']; |
||
415 | } else { |
||
416 | $data['fax'] = ''; |
||
417 | } |
||
418 | |||
419 | if (isset($this->request->post['image'])) { |
||
420 | $data['image'] = $this->request->post['image']; |
||
421 | } elseif (!empty($location_info)) { |
||
422 | $data['image'] = $location_info['image']; |
||
423 | } else { |
||
424 | $data['image'] = ''; |
||
425 | } |
||
426 | |||
427 | |||
428 | |||
429 | if (isset($this->request->post['image']) && is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $this->request->post['image'])) { |
||
430 | $data['thumb'] = '/public_html/assets/images/' . $this->request->post['image']; |
||
431 | } elseif (!empty($location_info) && is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $location_info['image'])) { |
||
432 | $data['thumb'] = '/public_html/assets/images/' . $location_info['image']; |
||
433 | } else { |
||
434 | $data['thumb'] = '/public_html/assets/images/no_image.png'; |
||
435 | } |
||
436 | |||
437 | $data['placeholder'] = '/public_html/assets/images/no_image.png'; |
||
438 | |||
439 | if (isset($this->request->post['open'])) { |
||
440 | $data['open'] = $this->request->post['open']; |
||
441 | } elseif (!empty($location_info)) { |
||
442 | $data['open'] = $location_info['open']; |
||
443 | } else { |
||
444 | $data['open'] = ''; |
||
445 | } |
||
446 | |||
447 | if (isset($this->request->post['comment'])) { |
||
448 | $data['comment'] = $this->request->post['comment']; |
||
449 | } elseif (!empty($location_info)) { |
||
450 | $data['comment'] = $location_info['comment']; |
||
451 | } else { |
||
452 | $data['comment'] = ''; |
||
453 | } |
||
454 | |||
455 | $data['header'] = $this->load->controller('common/header'); |
||
456 | $data['column'] = $this->load->controller('common/column_left'); |
||
457 | $data['footer'] = $this->load->controller('common/footer'); |
||
458 | |||
459 | $this->response->setOutput($this->load->view('localisation/location_form', $data)); |
||
460 | } |
||
492 |
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.