| Conditions | 40 |
| Paths | 0 |
| Total Lines | 225 |
| Code Lines | 155 |
| 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 |
||
| 252 | protected function getForm() |
||
| 253 | { |
||
| 254 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 255 | |||
| 256 | $data['text_form'] = !isset($this->request->get['blog_category_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
||
| 257 | $data['text_none'] = $this->language->get('text_none'); |
||
| 258 | $data['text_default'] = $this->language->get('text_default'); |
||
| 259 | $data['text_enabled'] = $this->language->get('text_enabled'); |
||
| 260 | $data['text_disabled'] = $this->language->get('text_disabled'); |
||
| 261 | |||
| 262 | $data['entry_name'] = $this->language->get('entry_name'); |
||
| 263 | $data['entry_description'] = $this->language->get('entry_description'); |
||
| 264 | $data['entry_meta_title'] = $this->language->get('entry_meta_title'); |
||
| 265 | $data['entry_meta_h1'] = $this->language->get('entry_meta_h1'); |
||
| 266 | $data['entry_meta_description'] = $this->language->get('entry_meta_description'); |
||
| 267 | $data['entry_keyword'] = $this->language->get('entry_keyword'); |
||
| 268 | $data['entry_parent'] = $this->language->get('entry_parent'); |
||
| 269 | $data['entry_image'] = $this->language->get('entry_image'); |
||
| 270 | $data['entry_top'] = $this->language->get('entry_top'); |
||
| 271 | $data['entry_column'] = $this->language->get('entry_column'); |
||
| 272 | $data['entry_sort_order'] = $this->language->get('entry_sort_order'); |
||
| 273 | $data['entry_status'] = $this->language->get('entry_status'); |
||
| 274 | $data['entry_noindex'] = $this->language->get('entry_noindex'); |
||
| 275 | $data['entry_layout'] = $this->language->get('entry_layout'); |
||
| 276 | |||
| 277 | $data['help_keyword'] = $this->language->get('help_keyword'); |
||
| 278 | $data['help_top'] = $this->language->get('help_top'); |
||
| 279 | $data['help_column'] = $this->language->get('help_column'); |
||
| 280 | $data['help_noindex'] = $this->language->get('help_noindex'); |
||
| 281 | |||
| 282 | $data['button_save'] = $this->language->get('button_save'); |
||
| 283 | $data['button_cancel'] = $this->language->get('button_cancel'); |
||
| 284 | |||
| 285 | $data['tab_general'] = $this->language->get('tab_general'); |
||
| 286 | $data['tab_data'] = $this->language->get('tab_data'); |
||
| 287 | $data['tab_design'] = $this->language->get('tab_design'); |
||
| 288 | |||
| 289 | if (isset($this->error['warning'])) { |
||
| 290 | $data['error_warning'] = $this->error['warning']; |
||
| 291 | } else { |
||
| 292 | $data['error_warning'] = ''; |
||
| 293 | } |
||
| 294 | |||
| 295 | if (isset($this->error['name'])) { |
||
| 296 | $data['error_name'] = $this->error['name']; |
||
| 297 | } else { |
||
| 298 | $data['error_name'] = array(); |
||
| 299 | } |
||
| 300 | |||
| 301 | if (isset($this->error['meta_title'])) { |
||
| 302 | $data['error_meta_title'] = $this->error['meta_title']; |
||
| 303 | } else { |
||
| 304 | $data['error_meta_title'] = array(); |
||
| 305 | } |
||
| 306 | |||
| 307 | if (isset($this->error['meta_h1'])) { |
||
| 308 | $data['error_meta_h1'] = $this->error['meta_h1']; |
||
| 309 | } else { |
||
| 310 | $data['error_meta_h1'] = array(); |
||
| 311 | } |
||
| 312 | |||
| 313 | if (isset($this->error['keyword'])) { |
||
| 314 | $data['error_keyword'] = $this->error['keyword']; |
||
| 315 | } else { |
||
| 316 | $data['error_keyword'] = ''; |
||
| 317 | } |
||
| 318 | |||
| 319 | $url = ''; |
||
| 320 | |||
| 321 | if (isset($this->request->get['sort'])) { |
||
| 322 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 323 | } |
||
| 324 | |||
| 325 | if (isset($this->request->get['order'])) { |
||
| 326 | $url .= '&order=' . $this->request->get['order']; |
||
| 327 | } |
||
| 328 | |||
| 329 | if (isset($this->request->get['page'])) { |
||
| 330 | $url .= '&page=' . $this->request->get['page']; |
||
| 331 | } |
||
| 332 | |||
| 333 | $data['breadcrumbs'] = array(); |
||
| 334 | |||
| 335 | $data['breadcrumbs'][] = array( |
||
| 336 | 'text' => $this->language->get('text_home'), |
||
| 337 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
| 338 | ); |
||
| 339 | |||
| 340 | $data['breadcrumbs'][] = array( |
||
| 341 | 'text' => $this->language->get('heading_title'), |
||
| 342 | 'href' => $this->url->link('blog/category', 'token=' . $this->session->data['token'] . $url, true) |
||
| 343 | ); |
||
| 344 | |||
| 345 | if (!isset($this->request->get['blog_category_id'])) { |
||
| 346 | $data['action'] = $this->url->link('blog/category/add', 'token=' . $this->session->data['token'] . $url, true); |
||
| 347 | } else { |
||
| 348 | $data['action'] = $this->url->link('blog/category/edit', 'token=' . $this->session->data['token'] . '&blog_category_id=' . $this->request->get['blog_category_id'] . $url, true); |
||
| 349 | } |
||
| 350 | |||
| 351 | $data['cancel'] = $this->url->link('blog/category', 'token=' . $this->session->data['token'] . $url, true); |
||
| 352 | |||
| 353 | if (isset($this->request->get['blog_category_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { |
||
| 354 | $category_info = $this->model_blog_category->getCategory($this->request->get['blog_category_id']); |
||
| 355 | } |
||
| 356 | |||
| 357 | $data['token'] = $this->session->data['token']; |
||
| 358 | |||
| 359 | $this->load->model('localisation/language'); |
||
| 360 | |||
| 361 | $data['languages'] = $this->model_localisation_language->getLanguages(); |
||
| 362 | |||
| 363 | if (isset($this->request->post['category_description'])) { |
||
| 364 | $data['category_description'] = $this->request->post['category_description']; |
||
| 365 | } elseif (isset($this->request->get['blog_category_id'])) { |
||
| 366 | $data['category_description'] = $this->model_blog_category->getCategoryDescriptions($this->request->get['blog_category_id']); |
||
| 367 | } else { |
||
| 368 | $data['category_description'] = array(); |
||
| 369 | } |
||
| 370 | |||
| 371 | $language_id = $this->config->get('config_language_id'); |
||
| 372 | if (isset($data['category_description'][$language_id]['name'])) { |
||
| 373 | $data['heading_title'] = $data['category_description'][$language_id]['name']; |
||
| 374 | } |
||
| 375 | |||
| 376 | if (isset($this->request->post['path'])) { |
||
| 377 | $data['path'] = $this->request->post['path']; |
||
| 378 | } elseif (!empty($category_info)) { |
||
| 379 | $data['path'] = $category_info['path']; |
||
| 380 | } else { |
||
| 381 | $data['path'] = ''; |
||
| 382 | } |
||
| 383 | |||
| 384 | if (isset($this->request->post['parent_id'])) { |
||
| 385 | $data['parent_id'] = $this->request->post['parent_id']; |
||
| 386 | } elseif (!empty($category_info)) { |
||
| 387 | $data['parent_id'] = $category_info['parent_id']; |
||
| 388 | } else { |
||
| 389 | $data['parent_id'] = 0; |
||
| 390 | } |
||
| 391 | |||
| 392 | if (isset($this->request->post['keyword'])) { |
||
| 393 | $data['keyword'] = $this->request->post['keyword']; |
||
| 394 | } elseif (!empty($category_info)) { |
||
| 395 | $data['keyword'] = $category_info['keyword']; |
||
| 396 | } else { |
||
| 397 | $data['keyword'] = ''; |
||
| 398 | } |
||
| 399 | |||
| 400 | if (isset($this->request->post['image'])) { |
||
| 401 | $data['image'] = $this->request->post['image']; |
||
| 402 | } elseif (!empty($category_info)) { |
||
| 403 | $data['image'] = $category_info['image']; |
||
| 404 | } else { |
||
| 405 | $data['image'] = ''; |
||
| 406 | } |
||
| 407 | |||
| 408 | |||
| 409 | |||
| 410 | if (isset($this->request->post['image']) && is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $this->request->post['image'])) { |
||
| 411 | $data['thumb'] = '/public_html/assets/images/' . $this->request->post['image']; |
||
| 412 | } elseif (!empty($article_info) && is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $category_info['image'])) { |
||
| 413 | $data['thumb'] = '/public_html/assets/images/' . $category_info['image']; |
||
| 414 | } else { |
||
| 415 | $data['thumb'] = '/public_html/assets/images/no_image.png'; |
||
| 416 | } |
||
| 417 | |||
| 418 | $data['placeholder'] = '/public_html/assets/images/no_image.png'; |
||
| 419 | |||
| 420 | if (isset($this->request->post['top'])) { |
||
| 421 | $data['top'] = $this->request->post['top']; |
||
| 422 | } elseif (!empty($category_info)) { |
||
| 423 | $data['top'] = $category_info['top']; |
||
| 424 | } else { |
||
| 425 | $data['top'] = 0; |
||
| 426 | } |
||
| 427 | |||
| 428 | if (isset($this->request->post['column'])) { |
||
| 429 | $data['column'] = $this->request->post['column']; |
||
| 430 | } elseif (!empty($category_info)) { |
||
| 431 | $data['column'] = $category_info['column']; |
||
| 432 | } else { |
||
| 433 | $data['column'] = 1; |
||
| 434 | } |
||
| 435 | |||
| 436 | if (isset($this->request->post['sort_order'])) { |
||
| 437 | $data['sort_order'] = $this->request->post['sort_order']; |
||
| 438 | } elseif (!empty($category_info)) { |
||
| 439 | $data['sort_order'] = $category_info['sort_order']; |
||
| 440 | } else { |
||
| 441 | $data['sort_order'] = 0; |
||
| 442 | } |
||
| 443 | |||
| 444 | if (isset($this->request->post['status'])) { |
||
| 445 | $data['status'] = $this->request->post['status']; |
||
| 446 | } elseif (!empty($category_info)) { |
||
| 447 | $data['status'] = $category_info['status']; |
||
| 448 | } else { |
||
| 449 | $data['status'] = true; |
||
| 450 | } |
||
| 451 | |||
| 452 | if (isset($this->request->post['noindex'])) { |
||
| 453 | $data['noindex'] = $this->request->post['noindex']; |
||
| 454 | } elseif (!empty($category_info)) { |
||
| 455 | $data['noindex'] = $category_info['noindex']; |
||
| 456 | } else { |
||
| 457 | $data['noindex'] = 1; |
||
| 458 | } |
||
| 459 | |||
| 460 | if (isset($this->request->post['category_layout'])) { |
||
| 461 | $data['category_layout'] = $this->request->post['category_layout']; |
||
| 462 | } elseif (isset($this->request->get['blog_category_id'])) { |
||
| 463 | $data['category_layout'] = $this->model_blog_category->getCategoryLayouts($this->request->get['blog_category_id']); |
||
| 464 | } else { |
||
| 465 | $data['category_layout'] = array(); |
||
| 466 | } |
||
| 467 | |||
| 468 | $this->load->model('design/layout'); |
||
| 469 | |||
| 470 | $data['layouts'] = $this->model_design_layout->getLayouts(); |
||
| 471 | |||
| 472 | $data['header'] = $this->load->controller('common/header'); |
||
| 473 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 474 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 475 | |||
| 476 | $this->response->setOutput($this->load->view('blog/category_form', $data)); |
||
| 477 | } |
||
| 711 |
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.