| Conditions | 18 |
| Paths | > 20000 |
| Total Lines | 148 |
| Code Lines | 92 |
| 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 |
||
| 139 | protected function getList() |
||
| 140 | { |
||
| 141 | if (isset($this->request->get['sort'])) { |
||
| 142 | $sort = $this->request->get['sort']; |
||
| 143 | } else { |
||
| 144 | $sort = 'name'; |
||
| 145 | } |
||
| 146 | |||
| 147 | if (isset($this->request->get['order'])) { |
||
| 148 | $order = $this->request->get['order']; |
||
| 149 | } else { |
||
| 150 | $order = 'ASC'; |
||
| 151 | } |
||
| 152 | |||
| 153 | if (isset($this->request->get['page'])) { |
||
| 154 | $page = $this->request->get['page']; |
||
| 155 | } else { |
||
| 156 | $page = 1; |
||
| 157 | } |
||
| 158 | |||
| 159 | $url = ''; |
||
| 160 | |||
| 161 | if (isset($this->request->get['sort'])) { |
||
| 162 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 163 | } |
||
| 164 | |||
| 165 | if (isset($this->request->get['order'])) { |
||
| 166 | $url .= '&order=' . $this->request->get['order']; |
||
| 167 | } |
||
| 168 | |||
| 169 | if (isset($this->request->get['page'])) { |
||
| 170 | $url .= '&page=' . $this->request->get['page']; |
||
| 171 | } |
||
| 172 | |||
| 173 | $data['breadcrumbs'] = array(); |
||
| 174 | |||
| 175 | $data['breadcrumbs'][] = array( |
||
| 176 | 'text' => $this->language->get('text_home'), |
||
| 177 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
| 178 | ); |
||
| 179 | |||
| 180 | $data['breadcrumbs'][] = array( |
||
| 181 | 'text' => $this->language->get('heading_title'), |
||
| 182 | 'href' => $this->url->link('design/banner', 'token=' . $this->session->data['token'] . $url, true) |
||
| 183 | ); |
||
| 184 | |||
| 185 | $data['add'] = $this->url->link('design/banner/add', 'token=' . $this->session->data['token'] . $url, true); |
||
| 186 | $data['delete'] = $this->url->link('design/banner/delete', 'token=' . $this->session->data['token'] . $url, true); |
||
| 187 | |||
| 188 | $data['banners'] = array(); |
||
| 189 | |||
| 190 | $filter_data = array( |
||
| 191 | 'sort' => $sort, |
||
| 192 | 'order' => $order, |
||
| 193 | 'start' => ($page - 1) * $this->config->get('config_limit_admin'), |
||
| 194 | 'limit' => $this->config->get('config_limit_admin') |
||
| 195 | ); |
||
| 196 | |||
| 197 | $banner_total = $this->model_design_banner->getTotalBanners(); |
||
| 198 | |||
| 199 | $results = $this->model_design_banner->getBanners($filter_data); |
||
| 200 | |||
| 201 | foreach ($results as $result) { |
||
| 202 | $data['banners'][] = array( |
||
| 203 | 'banner_id' => $result['banner_id'], |
||
| 204 | 'name' => $result['name'], |
||
| 205 | 'status' => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')), |
||
| 206 | 'edit' => $this->url->link('design/banner/edit', 'token=' . $this->session->data['token'] . '&banner_id=' . $result['banner_id'] . $url, true) |
||
| 207 | ); |
||
| 208 | } |
||
| 209 | |||
| 210 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 211 | |||
| 212 | $data['text_list'] = $this->language->get('text_list'); |
||
| 213 | $data['text_no_results'] = $this->language->get('text_no_results'); |
||
| 214 | $data['text_confirm'] = $this->language->get('text_confirm'); |
||
| 215 | |||
| 216 | $data['column_name'] = $this->language->get('column_name'); |
||
| 217 | $data['column_status'] = $this->language->get('column_status'); |
||
| 218 | $data['column_action'] = $this->language->get('column_action'); |
||
| 219 | |||
| 220 | $data['button_add'] = $this->language->get('button_add'); |
||
| 221 | $data['button_edit'] = $this->language->get('button_edit'); |
||
| 222 | $data['button_delete'] = $this->language->get('button_delete'); |
||
| 223 | |||
| 224 | if (isset($this->error['warning'])) { |
||
| 225 | $data['error_warning'] = $this->error['warning']; |
||
| 226 | } else { |
||
| 227 | $data['error_warning'] = ''; |
||
| 228 | } |
||
| 229 | |||
| 230 | if (isset($this->session->data['success'])) { |
||
| 231 | $data['success'] = $this->session->data['success']; |
||
| 232 | |||
| 233 | unset($this->session->data['success']); |
||
| 234 | } else { |
||
| 235 | $data['success'] = ''; |
||
| 236 | } |
||
| 237 | |||
| 238 | if (isset($this->request->post['selected'])) { |
||
| 239 | $data['selected'] = (array)$this->request->post['selected']; |
||
| 240 | } else { |
||
| 241 | $data['selected'] = array(); |
||
| 242 | } |
||
| 243 | |||
| 244 | $url = ''; |
||
| 245 | |||
| 246 | if ($order == 'ASC') { |
||
| 247 | $url .= '&order=DESC'; |
||
| 248 | } else { |
||
| 249 | $url .= '&order=ASC'; |
||
| 250 | } |
||
| 251 | |||
| 252 | if (isset($this->request->get['page'])) { |
||
| 253 | $url .= '&page=' . $this->request->get['page']; |
||
| 254 | } |
||
| 255 | |||
| 256 | $data['sort_name'] = $this->url->link('design/banner', 'token=' . $this->session->data['token'] . '&sort=name' . $url, true); |
||
| 257 | $data['sort_status'] = $this->url->link('design/banner', 'token=' . $this->session->data['token'] . '&sort=status' . $url, true); |
||
| 258 | |||
| 259 | $url = ''; |
||
| 260 | |||
| 261 | if (isset($this->request->get['sort'])) { |
||
| 262 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 263 | } |
||
| 264 | |||
| 265 | if (isset($this->request->get['order'])) { |
||
| 266 | $url .= '&order=' . $this->request->get['order']; |
||
| 267 | } |
||
| 268 | |||
| 269 | $pagination = new \Divine\Engine\Library\Pagination(); |
||
| 270 | $pagination->total = $banner_total; |
||
| 271 | $pagination->page = $page; |
||
| 272 | $pagination->limit = $this->config->get('config_limit_admin'); |
||
| 273 | $pagination->url = $this->url->link('design/banner', 'token=' . $this->session->data['token'] . $url . '&page={page}', true); |
||
| 274 | |||
| 275 | $data['pagination'] = $pagination->render(); |
||
| 276 | |||
| 277 | $data['results'] = sprintf($this->language->get('text_pagination'), ($banner_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($banner_total - $this->config->get('config_limit_admin'))) ? $banner_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $banner_total, ceil($banner_total / $this->config->get('config_limit_admin'))); |
||
| 278 | |||
| 279 | $data['sort'] = $sort; |
||
| 280 | $data['order'] = $order; |
||
| 281 | |||
| 282 | $data['header'] = $this->load->controller('common/header'); |
||
| 283 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 284 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 285 | |||
| 286 | $this->response->setOutput($this->load->view('design/banner_list', $data)); |
||
| 287 | } |
||
| 461 |
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.