| Conditions | 7 |
| Paths | 18 |
| Total Lines | 85 |
| Code Lines | 54 |
| 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 |
||
| 27 | public function index() |
||
| 28 | { |
||
| 29 | $this->load->language('tool/log'); |
||
| 30 | |||
| 31 | $this->document->setTitle($this->language->get('heading_title')); |
||
| 32 | |||
| 33 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 34 | |||
| 35 | $data['text_list'] = $this->language->get('text_list'); |
||
| 36 | $data['text_confirm'] = $this->language->get('text_confirm'); |
||
| 37 | |||
| 38 | $data['button_download'] = $this->language->get('button_download'); |
||
| 39 | $data['button_clear'] = $this->language->get('button_clear'); |
||
| 40 | |||
| 41 | if (isset($this->session->data['error'])) { |
||
| 42 | $data['error_warning'] = $this->session->data['error']; |
||
| 43 | |||
| 44 | unset($this->session->data['error']); |
||
| 45 | } elseif (isset($this->error['warning'])) { |
||
| 46 | $data['error_warning'] = $this->error['warning']; |
||
| 47 | } else { |
||
| 48 | $data['error_warning'] = ''; |
||
| 49 | } |
||
| 50 | |||
| 51 | if (isset($this->session->data['success'])) { |
||
| 52 | $data['success'] = $this->session->data['success']; |
||
| 53 | |||
| 54 | unset($this->session->data['success']); |
||
| 55 | } else { |
||
| 56 | $data['success'] = ''; |
||
| 57 | } |
||
| 58 | |||
| 59 | $data['breadcrumbs'] = array(); |
||
| 60 | |||
| 61 | $data['breadcrumbs'][] = array( |
||
| 62 | 'text' => $this->language->get('text_home'), |
||
| 63 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
| 64 | ); |
||
| 65 | |||
| 66 | $data['breadcrumbs'][] = array( |
||
| 67 | 'text' => $this->language->get('heading_title'), |
||
| 68 | 'href' => $this->url->link('tool/log', 'token=' . $this->session->data['token'], true) |
||
| 69 | ); |
||
| 70 | |||
| 71 | $data['download'] = $this->url->link('tool/log/download', 'token=' . $this->session->data['token'], true); |
||
| 72 | $data['clear'] = $this->url->link('tool/log/clear', 'token=' . $this->session->data['token'], true); |
||
| 73 | |||
| 74 | $data['log'] = ''; |
||
| 75 | |||
| 76 | $file = $_SERVER['DOCUMENT_ROOT'] . '/storage/logs/' . $this->config->get('config_error_filename'); |
||
| 77 | |||
| 78 | if (file_exists($file)) { |
||
| 79 | $size = filesize($file); |
||
| 80 | |||
| 81 | if ($size >= 5242880) { |
||
| 82 | $suffix = array( |
||
| 83 | 'B', |
||
| 84 | 'KB', |
||
| 85 | 'MB', |
||
| 86 | 'GB', |
||
| 87 | 'TB', |
||
| 88 | 'PB', |
||
| 89 | 'EB', |
||
| 90 | 'ZB', |
||
| 91 | 'YB' |
||
| 92 | ); |
||
| 93 | |||
| 94 | $i = 0; |
||
| 95 | |||
| 96 | while (($size / 1024) > 1) { |
||
| 97 | $size = $size / 1024; |
||
| 98 | $i++; |
||
| 99 | } |
||
| 100 | |||
| 101 | $data['error_warning'] = sprintf($this->language->get('error_warning'), basename($file), round(substr($size, 0, strpos($size, '.') + 4), 2) . $suffix[$i]); |
||
| 102 | } else { |
||
| 103 | $data['log'] = file_get_contents($file, FILE_USE_INCLUDE_PATH, null); |
||
| 104 | } |
||
| 105 | } |
||
| 106 | |||
| 107 | $data['header'] = $this->load->controller('common/header'); |
||
| 108 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 109 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 110 | |||
| 111 | $this->response->setOutput($this->load->view('tool/log', $data)); |
||
| 112 | } |
||
| 155 |
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.