| Conditions | 4 |
| Paths | 6 |
| Total Lines | 57 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 20 | public function index() |
||
| 21 | { |
||
| 22 | $this->load->language('extension/extension'); |
||
| 23 | $this->document->setTitle($this->language->get('heading_title')); |
||
| 24 | |||
| 25 | $data['breadcrumbs'] = array(); |
||
| 26 | |||
| 27 | $data['breadcrumbs'][] = array( |
||
| 28 | 'text' => $this->language->get('text_home'), |
||
| 29 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
| 30 | ); |
||
| 31 | |||
| 32 | $data['breadcrumbs'][] = array( |
||
| 33 | 'text' => $this->language->get('heading_title'), |
||
| 34 | 'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'], true) |
||
| 35 | ); |
||
| 36 | |||
| 37 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 38 | $data['text_list'] = $this->language->get('text_list'); |
||
| 39 | $data['text_type'] = $this->language->get('text_type'); |
||
| 40 | $data['text_filter'] = $this->language->get('text_filter'); |
||
| 41 | $data['text_loading'] = $this->language->get('text_loading'); |
||
| 42 | $data['text_confirm'] = $this->language->get('text_confirm'); |
||
| 43 | |||
| 44 | $data['token'] = $this->session->data['token']; |
||
| 45 | |||
| 46 | if (isset($this->request->get['type'])) { |
||
| 47 | $data['type'] = $this->request->get['type']; |
||
| 48 | } else { |
||
| 49 | $data['type'] = 'module'; |
||
| 50 | } |
||
| 51 | |||
| 52 | $data['categories'] = array(); |
||
| 53 | |||
| 54 | $files = glob(SR_APPLICATION . 'controller/extension/extension/*.php', GLOB_BRACE); |
||
| 55 | |||
| 56 | foreach ($files as $file) { |
||
| 57 | $extension = basename($file, '.php'); |
||
| 58 | |||
| 59 | $this->load->language('extension/extension/' . $extension); |
||
| 60 | |||
| 61 | if ($this->user->hasPermission('access', 'extension/extension/' . $extension)) { |
||
| 62 | $files = glob(SR_APPLICATION . 'controller/{extension/' . $extension . ',' . $extension . '}/*.php', GLOB_BRACE); |
||
| 63 | |||
| 64 | $data['categories'][] = array( |
||
| 65 | 'code' => $extension, |
||
| 66 | 'text' => $this->language->get('heading_title') . ' (' . count($files) . ')', |
||
| 67 | 'href' => $this->url->link('extension/extension/' . $extension, 'token=' . $this->session->data['token'], true) |
||
| 68 | ); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | $data['header'] = $this->load->controller('common/header'); |
||
| 73 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 74 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 75 | |||
| 76 | $this->response->setOutput($this->load->view('extension/extension', $data)); |
||
| 77 | } |
||
| 79 |
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.