| Conditions | 34 |
| Paths | > 20000 |
| Total Lines | 254 |
| Code Lines | 162 |
| 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 |
||
| 187 | protected function getList() |
||
| 188 | { |
||
| 189 | if (isset($this->request->get['filter_product'])) { |
||
| 190 | $filter_product = $this->request->get['filter_product']; |
||
| 191 | } else { |
||
| 192 | $filter_product = null; |
||
| 193 | } |
||
| 194 | |||
| 195 | if (isset($this->request->get['filter_author'])) { |
||
| 196 | $filter_author = $this->request->get['filter_author']; |
||
| 197 | } else { |
||
| 198 | $filter_author = null; |
||
| 199 | } |
||
| 200 | |||
| 201 | if (isset($this->request->get['filter_status'])) { |
||
| 202 | $filter_status = $this->request->get['filter_status']; |
||
| 203 | } else { |
||
| 204 | $filter_status = null; |
||
| 205 | } |
||
| 206 | |||
| 207 | if (isset($this->request->get['filter_date_added'])) { |
||
| 208 | $filter_date_added = $this->request->get['filter_date_added']; |
||
| 209 | } else { |
||
| 210 | $filter_date_added = null; |
||
| 211 | } |
||
| 212 | |||
| 213 | if (isset($this->request->get['order'])) { |
||
| 214 | $order = $this->request->get['order']; |
||
| 215 | } else { |
||
| 216 | $order = 'DESC'; |
||
| 217 | } |
||
| 218 | |||
| 219 | if (isset($this->request->get['sort'])) { |
||
| 220 | $sort = $this->request->get['sort']; |
||
| 221 | } else { |
||
| 222 | $sort = 'r.date_added'; |
||
| 223 | } |
||
| 224 | |||
| 225 | if (isset($this->request->get['page'])) { |
||
| 226 | $page = $this->request->get['page']; |
||
| 227 | } else { |
||
| 228 | $page = 1; |
||
| 229 | } |
||
| 230 | |||
| 231 | $url = ''; |
||
| 232 | |||
| 233 | if (isset($this->request->get['filter_product'])) { |
||
| 234 | $url .= '&filter_product=' . urlencode(html_entity_decode($this->request->get['filter_product'], ENT_QUOTES, 'UTF-8')); |
||
| 235 | } |
||
| 236 | |||
| 237 | if (isset($this->request->get['filter_author'])) { |
||
| 238 | $url .= '&filter_author=' . urlencode(html_entity_decode($this->request->get['filter_author'], ENT_QUOTES, 'UTF-8')); |
||
| 239 | } |
||
| 240 | |||
| 241 | if (isset($this->request->get['filter_status'])) { |
||
| 242 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||
| 243 | } |
||
| 244 | |||
| 245 | if (isset($this->request->get['filter_date_added'])) { |
||
| 246 | $url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
||
| 247 | } |
||
| 248 | |||
| 249 | if (isset($this->request->get['sort'])) { |
||
| 250 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 251 | } |
||
| 252 | |||
| 253 | if (isset($this->request->get['order'])) { |
||
| 254 | $url .= '&order=' . $this->request->get['order']; |
||
| 255 | } |
||
| 256 | |||
| 257 | if (isset($this->request->get['page'])) { |
||
| 258 | $url .= '&page=' . $this->request->get['page']; |
||
| 259 | } |
||
| 260 | |||
| 261 | $data['breadcrumbs'] = array(); |
||
| 262 | |||
| 263 | $data['breadcrumbs'][] = array( |
||
| 264 | 'text' => $this->language->get('text_home'), |
||
| 265 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
| 266 | ); |
||
| 267 | |||
| 268 | $data['breadcrumbs'][] = array( |
||
| 269 | 'text' => $this->language->get('heading_title'), |
||
| 270 | 'href' => $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . $url, true) |
||
| 271 | ); |
||
| 272 | |||
| 273 | $data['add'] = $this->url->link('catalog/review/add', 'token=' . $this->session->data['token'] . $url, true); |
||
| 274 | $data['delete'] = $this->url->link('catalog/review/delete', 'token=' . $this->session->data['token'] . $url, true); |
||
| 275 | $data['enabled'] = $this->url->link('catalog/review/enable', 'token=' . $this->session->data['token'] . $url, true); |
||
| 276 | $data['disabled'] = $this->url->link('catalog/review/disable', 'token=' . $this->session->data['token'] . $url, true); |
||
| 277 | |||
| 278 | |||
| 279 | $data['reviews'] = array(); |
||
| 280 | |||
| 281 | $filter_data = array( |
||
| 282 | 'filter_product' => $filter_product, |
||
| 283 | 'filter_author' => $filter_author, |
||
| 284 | 'filter_status' => $filter_status, |
||
| 285 | 'filter_date_added' => $filter_date_added, |
||
| 286 | 'sort' => $sort, |
||
| 287 | 'order' => $order, |
||
| 288 | 'start' => ($page - 1) * $this->config->get('config_limit_admin'), |
||
| 289 | 'limit' => $this->config->get('config_limit_admin') |
||
| 290 | ); |
||
| 291 | |||
| 292 | $review_total = $this->model_catalog_review->getTotalReviews($filter_data); |
||
| 293 | |||
| 294 | $results = $this->model_catalog_review->getReviews($filter_data); |
||
| 295 | |||
| 296 | foreach ($results as $result) { |
||
| 297 | $data['reviews'][] = array( |
||
| 298 | 'review_id' => $result['review_id'], |
||
| 299 | 'name' => $result['name'], |
||
| 300 | 'author' => $result['author'], |
||
| 301 | 'rating' => $result['rating'], |
||
| 302 | 'status' => ($result['status']) ? $this->language->get('text_enabled') : $this->language->get('text_disabled'), |
||
| 303 | 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])), |
||
| 304 | 'edit' => $this->url->link('catalog/review/edit', 'token=' . $this->session->data['token'] . '&review_id=' . $result['review_id'] . $url, true) |
||
| 305 | ); |
||
| 306 | } |
||
| 307 | |||
| 308 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 309 | |||
| 310 | $data['text_list'] = $this->language->get('text_list'); |
||
| 311 | $data['text_no_results'] = $this->language->get('text_no_results'); |
||
| 312 | $data['text_confirm'] = $this->language->get('text_confirm'); |
||
| 313 | $data['text_enabled'] = $this->language->get('text_enabled'); |
||
| 314 | $data['text_disabled'] = $this->language->get('text_disabled'); |
||
| 315 | |||
| 316 | $data['column_product'] = $this->language->get('column_product'); |
||
| 317 | $data['column_author'] = $this->language->get('column_author'); |
||
| 318 | $data['column_rating'] = $this->language->get('column_rating'); |
||
| 319 | $data['column_status'] = $this->language->get('column_status'); |
||
| 320 | $data['column_date_added'] = $this->language->get('column_date_added'); |
||
| 321 | $data['column_action'] = $this->language->get('column_action'); |
||
| 322 | |||
| 323 | $data['entry_product'] = $this->language->get('entry_product'); |
||
| 324 | $data['entry_author'] = $this->language->get('entry_author'); |
||
| 325 | $data['entry_rating'] = $this->language->get('entry_rating'); |
||
| 326 | $data['entry_status'] = $this->language->get('entry_status'); |
||
| 327 | $data['entry_date_added'] = $this->language->get('entry_date_added'); |
||
| 328 | |||
| 329 | $data['button_add'] = $this->language->get('button_add'); |
||
| 330 | $data['button_edit'] = $this->language->get('button_edit'); |
||
| 331 | $data['button_delete'] = $this->language->get('button_delete'); |
||
| 332 | $data['button_filter'] = $this->language->get('button_filter'); |
||
| 333 | $data['button_enable'] = $this->language->get('button_enable'); |
||
| 334 | $data['button_disable'] = $this->language->get('button_disable'); |
||
| 335 | |||
| 336 | $data['token'] = $this->session->data['token']; |
||
| 337 | |||
| 338 | if (isset($this->error['warning'])) { |
||
| 339 | $data['error_warning'] = $this->error['warning']; |
||
| 340 | } else { |
||
| 341 | $data['error_warning'] = ''; |
||
| 342 | } |
||
| 343 | |||
| 344 | if (isset($this->session->data['success'])) { |
||
| 345 | $data['success'] = $this->session->data['success']; |
||
| 346 | |||
| 347 | unset($this->session->data['success']); |
||
| 348 | } else { |
||
| 349 | $data['success'] = ''; |
||
| 350 | } |
||
| 351 | |||
| 352 | if (isset($this->request->post['selected'])) { |
||
| 353 | $data['selected'] = (array)$this->request->post['selected']; |
||
| 354 | } else { |
||
| 355 | $data['selected'] = array(); |
||
| 356 | } |
||
| 357 | |||
| 358 | $url = ''; |
||
| 359 | |||
| 360 | if (isset($this->request->get['filter_product'])) { |
||
| 361 | $url .= '&filter_product=' . urlencode(html_entity_decode($this->request->get['filter_product'], ENT_QUOTES, 'UTF-8')); |
||
| 362 | } |
||
| 363 | |||
| 364 | if (isset($this->request->get['filter_author'])) { |
||
| 365 | $url .= '&filter_author=' . urlencode(html_entity_decode($this->request->get['filter_author'], ENT_QUOTES, 'UTF-8')); |
||
| 366 | } |
||
| 367 | |||
| 368 | if (isset($this->request->get['filter_status'])) { |
||
| 369 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||
| 370 | } |
||
| 371 | |||
| 372 | if (isset($this->request->get['filter_date_added'])) { |
||
| 373 | $url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
||
| 374 | } |
||
| 375 | |||
| 376 | if ($order == 'ASC') { |
||
| 377 | $url .= '&order=DESC'; |
||
| 378 | } else { |
||
| 379 | $url .= '&order=ASC'; |
||
| 380 | } |
||
| 381 | |||
| 382 | if (isset($this->request->get['page'])) { |
||
| 383 | $url .= '&page=' . $this->request->get['page']; |
||
| 384 | } |
||
| 385 | |||
| 386 | $data['sort_product'] = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . '&sort=pd.name' . $url, true); |
||
| 387 | $data['sort_author'] = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . '&sort=r.author' . $url, true); |
||
| 388 | $data['sort_rating'] = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . '&sort=r.rating' . $url, true); |
||
| 389 | $data['sort_status'] = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . '&sort=r.status' . $url, true); |
||
| 390 | $data['sort_date_added'] = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . '&sort=r.date_added' . $url, true); |
||
| 391 | |||
| 392 | $url = ''; |
||
| 393 | |||
| 394 | if (isset($this->request->get['filter_product'])) { |
||
| 395 | $url .= '&filter_product=' . urlencode(html_entity_decode($this->request->get['filter_product'], ENT_QUOTES, 'UTF-8')); |
||
| 396 | } |
||
| 397 | |||
| 398 | if (isset($this->request->get['filter_author'])) { |
||
| 399 | $url .= '&filter_author=' . urlencode(html_entity_decode($this->request->get['filter_author'], ENT_QUOTES, 'UTF-8')); |
||
| 400 | } |
||
| 401 | |||
| 402 | if (isset($this->request->get['filter_status'])) { |
||
| 403 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||
| 404 | } |
||
| 405 | |||
| 406 | if (isset($this->request->get['filter_date_added'])) { |
||
| 407 | $url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
||
| 408 | } |
||
| 409 | |||
| 410 | if (isset($this->request->get['sort'])) { |
||
| 411 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 412 | } |
||
| 413 | |||
| 414 | if (isset($this->request->get['order'])) { |
||
| 415 | $url .= '&order=' . $this->request->get['order']; |
||
| 416 | } |
||
| 417 | |||
| 418 | $pagination = new \Divine\Engine\Library\Pagination(); |
||
| 419 | $pagination->total = $review_total; |
||
| 420 | $pagination->page = $page; |
||
| 421 | $pagination->limit = $this->config->get('config_limit_admin'); |
||
| 422 | $pagination->url = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . $url . '&page={page}', true); |
||
| 423 | |||
| 424 | $data['pagination'] = $pagination->render(); |
||
| 425 | |||
| 426 | $data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($review_total - $this->config->get('config_limit_admin'))) ? $review_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $review_total, ceil($review_total / $this->config->get('config_limit_admin'))); |
||
| 427 | |||
| 428 | $data['filter_product'] = $filter_product; |
||
| 429 | $data['filter_author'] = $filter_author; |
||
| 430 | $data['filter_status'] = $filter_status; |
||
| 431 | $data['filter_date_added'] = $filter_date_added; |
||
| 432 | |||
| 433 | $data['sort'] = $sort; |
||
| 434 | $data['order'] = $order; |
||
| 435 | |||
| 436 | $data['header'] = $this->load->controller('common/header'); |
||
| 437 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 438 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 439 | |||
| 440 | $this->response->setOutput($this->load->view('catalog/review_list', $data)); |
||
| 441 | } |
||
| 709 |
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.