| Conditions | 25 |
| Paths | > 20000 |
| Total Lines | 196 |
| Code Lines | 121 |
| 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 |
||
| 88 | protected function getList() |
||
| 89 | { |
||
| 90 | if (isset($this->request->get['filter_name'])) { |
||
| 91 | $filter_name = $this->request->get['filter_name']; |
||
| 92 | } else { |
||
| 93 | $filter_name = null; |
||
| 94 | } |
||
| 95 | |||
| 96 | if (isset($this->request->get['filter_date_added'])) { |
||
| 97 | $filter_date_added = $this->request->get['filter_date_added']; |
||
| 98 | } else { |
||
| 99 | $filter_date_added = null; |
||
| 100 | } |
||
| 101 | |||
| 102 | if (isset($this->request->get['sort'])) { |
||
| 103 | $sort = $this->request->get['sort']; |
||
| 104 | } else { |
||
| 105 | $sort = 'date_added'; |
||
| 106 | } |
||
| 107 | |||
| 108 | if (isset($this->request->get['order'])) { |
||
| 109 | $order = $this->request->get['order']; |
||
| 110 | } else { |
||
| 111 | $order = 'DESC'; |
||
| 112 | } |
||
| 113 | |||
| 114 | if (isset($this->request->get['page'])) { |
||
| 115 | $page = $this->request->get['page']; |
||
| 116 | } else { |
||
| 117 | $page = 1; |
||
| 118 | } |
||
| 119 | |||
| 120 | $url = ''; |
||
| 121 | |||
| 122 | if (isset($this->request->get['filter_name'])) { |
||
| 123 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||
| 124 | } |
||
| 125 | |||
| 126 | if (isset($this->request->get['filter_date_added'])) { |
||
| 127 | $url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
||
| 128 | } |
||
| 129 | |||
| 130 | if (isset($this->request->get['sort'])) { |
||
| 131 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 132 | } |
||
| 133 | |||
| 134 | if (isset($this->request->get['order'])) { |
||
| 135 | $url .= '&order=' . $this->request->get['order']; |
||
| 136 | } |
||
| 137 | |||
| 138 | if (isset($this->request->get['page'])) { |
||
| 139 | $url .= '&page=' . $this->request->get['page']; |
||
| 140 | } |
||
| 141 | |||
| 142 | $data['breadcrumbs'] = array(); |
||
| 143 | |||
| 144 | $data['breadcrumbs'][] = array( |
||
| 145 | 'text' => $this->language->get('text_home'), |
||
| 146 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
| 147 | ); |
||
| 148 | |||
| 149 | $data['breadcrumbs'][] = array( |
||
| 150 | 'text' => $this->language->get('heading_title'), |
||
| 151 | 'href' => $this->url->link('tool/upload', 'token=' . $this->session->data['token'] . $url, true) |
||
| 152 | ); |
||
| 153 | |||
| 154 | $data['delete'] = $this->url->link('tool/upload/delete', 'token=' . $this->session->data['token'] . $url, true); |
||
| 155 | |||
| 156 | $data['uploads'] = array(); |
||
| 157 | |||
| 158 | $filter_data = array( |
||
| 159 | 'filter_name' => $filter_name, |
||
| 160 | 'filter_date_added' => $filter_date_added, |
||
| 161 | 'sort' => $sort, |
||
| 162 | 'order' => $order, |
||
| 163 | 'start' => ($page - 1) * $this->config->get('config_limit_admin'), |
||
| 164 | 'limit' => $this->config->get('config_limit_admin') |
||
| 165 | ); |
||
| 166 | |||
| 167 | $upload_total = $this->model_tool_upload->getTotalUploads($filter_data); |
||
| 168 | |||
| 169 | $results = $this->model_tool_upload->getUploads($filter_data); |
||
| 170 | |||
| 171 | foreach ($results as $result) { |
||
| 172 | $data['uploads'][] = array( |
||
| 173 | 'upload_id' => $result['upload_id'], |
||
| 174 | 'name' => $result['name'], |
||
| 175 | 'filename' => $result['filename'], |
||
| 176 | 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])), |
||
| 177 | 'download' => $this->url->link('tool/upload/download', 'token=' . $this->session->data['token'] . '&code=' . $result['code'] . $url, true) |
||
| 178 | ); |
||
| 179 | } |
||
| 180 | |||
| 181 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 182 | |||
| 183 | $data['text_list'] = $this->language->get('text_list'); |
||
| 184 | $data['text_no_results'] = $this->language->get('text_no_results'); |
||
| 185 | $data['text_confirm'] = $this->language->get('text_confirm'); |
||
| 186 | |||
| 187 | $data['column_name'] = $this->language->get('column_name'); |
||
| 188 | $data['column_filename'] = $this->language->get('column_filename'); |
||
| 189 | $data['column_date_added'] = $this->language->get('column_date_added'); |
||
| 190 | $data['column_action'] = $this->language->get('column_action'); |
||
| 191 | |||
| 192 | $data['entry_name'] = $this->language->get('entry_name'); |
||
| 193 | $data['entry_date_added'] = $this->language->get('entry_date_added'); |
||
| 194 | |||
| 195 | $data['button_download'] = $this->language->get('button_download'); |
||
| 196 | $data['button_delete'] = $this->language->get('button_delete'); |
||
| 197 | $data['button_filter'] = $this->language->get('button_filter'); |
||
| 198 | |||
| 199 | $data['token'] = $this->session->data['token']; |
||
| 200 | |||
| 201 | if (isset($this->error['warning'])) { |
||
| 202 | $data['error_warning'] = $this->error['warning']; |
||
| 203 | } else { |
||
| 204 | $data['error_warning'] = ''; |
||
| 205 | } |
||
| 206 | |||
| 207 | if (isset($this->session->data['success'])) { |
||
| 208 | $data['success'] = $this->session->data['success']; |
||
| 209 | |||
| 210 | unset($this->session->data['success']); |
||
| 211 | } else { |
||
| 212 | $data['success'] = ''; |
||
| 213 | } |
||
| 214 | |||
| 215 | if (isset($this->request->post['selected'])) { |
||
| 216 | $data['selected'] = (array)$this->request->post['selected']; |
||
| 217 | } else { |
||
| 218 | $data['selected'] = array(); |
||
| 219 | } |
||
| 220 | |||
| 221 | $url = ''; |
||
| 222 | |||
| 223 | if (isset($this->request->get['filter_name'])) { |
||
| 224 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||
| 225 | } |
||
| 226 | |||
| 227 | if (isset($this->request->get['filter_date_added'])) { |
||
| 228 | $url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
||
| 229 | } |
||
| 230 | |||
| 231 | if ($order == 'ASC') { |
||
| 232 | $url .= '&order=DESC'; |
||
| 233 | } else { |
||
| 234 | $url .= '&order=ASC'; |
||
| 235 | } |
||
| 236 | |||
| 237 | if (isset($this->request->get['page'])) { |
||
| 238 | $url .= '&page=' . $this->request->get['page']; |
||
| 239 | } |
||
| 240 | |||
| 241 | $data['sort_name'] = $this->url->link('tool/upload', 'token=' . $this->session->data['token'] . '&sort=name' . $url, true); |
||
| 242 | $data['sort_filename'] = $this->url->link('tool/upload', 'token=' . $this->session->data['token'] . '&sort=filename' . $url, true); |
||
| 243 | $data['sort_date_added'] = $this->url->link('tool/upload', 'token=' . $this->session->data['token'] . '&sort=date_added' . $url, true); |
||
| 244 | |||
| 245 | $url = ''; |
||
| 246 | |||
| 247 | if (isset($this->request->get['filter_name'])) { |
||
| 248 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||
| 249 | } |
||
| 250 | |||
| 251 | if (isset($this->request->get['filter_date_added'])) { |
||
| 252 | $url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
||
| 253 | } |
||
| 254 | |||
| 255 | if (isset($this->request->get['sort'])) { |
||
| 256 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 257 | } |
||
| 258 | |||
| 259 | if (isset($this->request->get['order'])) { |
||
| 260 | $url .= '&order=' . $this->request->get['order']; |
||
| 261 | } |
||
| 262 | |||
| 263 | $pagination = new \Divine\Engine\Library\Pagination(); |
||
| 264 | $pagination->total = $upload_total; |
||
| 265 | $pagination->page = $page; |
||
| 266 | $pagination->limit = $this->config->get('config_limit_admin'); |
||
| 267 | $pagination->url = $this->url->link('tool/upload', 'token=' . $this->session->data['token'] . $url . '&page={page}', true); |
||
| 268 | |||
| 269 | $data['pagination'] = $pagination->render(); |
||
| 270 | |||
| 271 | $data['results'] = sprintf($this->language->get('text_pagination'), ($upload_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($upload_total - $this->config->get('config_limit_admin'))) ? $upload_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $upload_total, ceil($upload_total / $this->config->get('config_limit_admin'))); |
||
| 272 | |||
| 273 | $data['filter_name'] = $filter_name; |
||
| 274 | $data['filter_date_added'] = $filter_date_added; |
||
| 275 | |||
| 276 | $data['sort'] = $sort; |
||
| 277 | $data['order'] = $order; |
||
| 278 | |||
| 279 | $data['header'] = $this->load->controller('common/header'); |
||
| 280 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 281 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 282 | |||
| 283 | $this->response->setOutput($this->load->view('tool/upload', $data)); |
||
| 284 | } |
||
| 442 |
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.