| Conditions | 27 |
| Paths | > 20000 |
| Total Lines | 150 |
| Code Lines | 100 |
| 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 |
||
| 303 | protected function getForm() |
||
| 304 | { |
||
| 305 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 306 | |||
| 307 | $data['text_form'] = !isset($this->request->get['benefit_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
||
| 308 | $data['text_enabled'] = $this->language->get('text_enabled'); |
||
| 309 | $data['text_disabled'] = $this->language->get('text_disabled'); |
||
| 310 | $data['text_default'] = $this->language->get('text_default'); |
||
| 311 | $data['text_image_manager'] = $this->language->get('text_image_manager'); |
||
| 312 | $data['text_browse'] = $this->language->get('text_browse'); |
||
| 313 | $data['text_clear'] = $this->language->get('text_clear'); |
||
| 314 | $data['text_type_benefit'] = $this->language->get('text_type_benefit'); |
||
| 315 | $data['text_type_gift'] = $this->language->get('text_type_gift'); |
||
| 316 | |||
| 317 | $data['entry_name'] = $this->language->get('entry_name'); |
||
| 318 | $data['entry_image'] = $this->language->get('entry_image'); |
||
| 319 | $data['entry_link'] = $this->language->get('entry_link'); |
||
| 320 | $data['entry_status'] = $this->language->get('entry_status'); |
||
| 321 | $data['entry_type'] = $this->language->get('entry_type'); |
||
| 322 | $data['entry_description'] = $this->language->get('entry_description'); |
||
| 323 | |||
| 324 | $data['button_save'] = $this->language->get('button_save'); |
||
| 325 | $data['button_cancel'] = $this->language->get('button_cancel'); |
||
| 326 | $data['button_remove'] = $this->language->get('button_remove'); |
||
| 327 | |||
| 328 | if (isset($this->error['warning'])) { |
||
| 329 | $data['error_warning'] = $this->error['warning']; |
||
| 330 | } else { |
||
| 331 | $data['error_warning'] = ''; |
||
| 332 | } |
||
| 333 | |||
| 334 | if (isset($this->error['name'])) { |
||
| 335 | $data['error_name'] = $this->error['name']; |
||
| 336 | } else { |
||
| 337 | $data['error_name'] = ''; |
||
| 338 | } |
||
| 339 | |||
| 340 | $url = ''; |
||
| 341 | |||
| 342 | if (isset($this->request->get['sort'])) { |
||
| 343 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 344 | } |
||
| 345 | |||
| 346 | if (isset($this->request->get['order'])) { |
||
| 347 | $url .= '&order=' . $this->request->get['order']; |
||
| 348 | } |
||
| 349 | |||
| 350 | if (isset($this->request->get['page'])) { |
||
| 351 | $url .= '&page=' . $this->request->get['page']; |
||
| 352 | } |
||
| 353 | |||
| 354 | $data['breadcrumbs'] = array(); |
||
| 355 | |||
| 356 | $data['breadcrumbs'][] = array( |
||
| 357 | 'text' => $this->language->get('text_home'), |
||
| 358 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true), |
||
| 359 | 'separator' => false |
||
| 360 | ); |
||
| 361 | |||
| 362 | $data['breadcrumbs'][] = array( |
||
| 363 | 'text' => $this->language->get('heading_title'), |
||
| 364 | 'href' => $this->url->link('design/benefit', 'token=' . $this->session->data['token'] . $url, true), |
||
| 365 | 'separator' => ' :: ' |
||
| 366 | ); |
||
| 367 | |||
| 368 | if (!isset($this->request->get['benefit_id'])) { |
||
| 369 | $data['action'] = $this->url->link('design/benefit/add', 'token=' . $this->session->data['token'] . $url, true); |
||
| 370 | } else { |
||
| 371 | $data['action'] = $this->url->link('design/benefit/edit', 'token=' . $this->session->data['token'] . '&benefit_id=' . $this->request->get['benefit_id'] . $url, true); |
||
| 372 | } |
||
| 373 | |||
| 374 | $data['cancel'] = $this->url->link('design/benefit', 'token=' . $this->session->data['token'] . $url, true); |
||
| 375 | |||
| 376 | if (isset($this->request->get['benefit_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { |
||
| 377 | $benefit_info = $this->model_design_benefit->getBenefit($this->request->get['benefit_id']); |
||
| 378 | } |
||
| 379 | |||
| 380 | $data['token'] = $this->session->data['token']; |
||
| 381 | |||
| 382 | |||
| 383 | $this->load->model('localisation/language'); |
||
| 384 | |||
| 385 | $data['languages'] = $this->model_localisation_language->getLanguages(); |
||
| 386 | |||
| 387 | if (isset($this->request->post['benefit_description'])) { |
||
| 388 | $data['benefit_description'] = $this->request->post['benefit_description']; |
||
| 389 | } elseif (isset($this->request->get['benefit_id'])) { |
||
| 390 | $data['benefit_description'] = $this->model_design_benefit->getBenefitDescriptions($this->request->get['benefit_id']); |
||
| 391 | } else { |
||
| 392 | $data['benefit_description'] = array(); |
||
| 393 | } |
||
| 394 | |||
| 395 | |||
| 396 | if (isset($this->request->post['name'])) { |
||
| 397 | $data['name'] = $this->request->post['name']; |
||
| 398 | } elseif (!empty($benefit_info)) { |
||
| 399 | $data['name'] = $benefit_info['name']; |
||
| 400 | } else { |
||
| 401 | $data['name'] = ''; |
||
| 402 | } |
||
| 403 | |||
| 404 | if (isset($this->request->post['status'])) { |
||
| 405 | $data['status'] = $this->request->post['status']; |
||
| 406 | } elseif (!empty($benefit_info)) { |
||
| 407 | $data['status'] = $benefit_info['status']; |
||
| 408 | } else { |
||
| 409 | $data['status'] = true; |
||
| 410 | } |
||
| 411 | |||
| 412 | if (isset($this->request->post['type'])) { |
||
| 413 | $data['type'] = $this->request->post['type']; |
||
| 414 | } elseif (!empty($benefit_info)) { |
||
| 415 | $data['type'] = $benefit_info['type']; |
||
| 416 | } else { |
||
| 417 | $data['type'] = true; |
||
| 418 | } |
||
| 419 | |||
| 420 | if (isset($this->request->post['link'])) { |
||
| 421 | $data['link'] = $this->request->post['link']; |
||
| 422 | } elseif (!empty($benefit_info)) { |
||
| 423 | $data['link'] = $benefit_info['link']; |
||
| 424 | } else { |
||
| 425 | $data['link'] = ''; |
||
| 426 | } |
||
| 427 | |||
| 428 | if (isset($this->request->post['image'])) { |
||
| 429 | $data['image'] = $this->request->post['image']; |
||
| 430 | } elseif (!empty($benefit_info)) { |
||
| 431 | $data['image'] = $benefit_info['image']; |
||
| 432 | } else { |
||
| 433 | $data['image'] = ''; |
||
| 434 | } |
||
| 435 | |||
| 436 | |||
| 437 | |||
| 438 | if (isset($this->request->post['image']) && file_exists($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $this->request->post['image'])) { |
||
| 439 | $data['thumb'] = '/public_html/assets/images/' . $this->request->post['image']; |
||
| 440 | } elseif (!empty($benefit_info) && $benefit_info['image'] && file_exists($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $benefit_info['image'])) { |
||
| 441 | $data['thumb'] = '/public_html/assets/images/' . $benefit_info['image']; |
||
| 442 | } else { |
||
| 443 | $data['thumb'] = '/public_html/assets/images/no_image.png'; |
||
| 444 | } |
||
| 445 | |||
| 446 | $data['placeholder'] = '/public_html/assets/images/no_image.png'; |
||
| 447 | |||
| 448 | $data['header'] = $this->load->controller('common/header'); |
||
| 449 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 450 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 451 | |||
| 452 | $this->response->setOutput($this->load->view('design/benefit_form', $data)); |
||
| 453 | } |
||
| 496 |
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.