| Conditions | 24 |
| Paths | 6656 |
| Total Lines | 90 |
| Code Lines | 46 |
| 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 |
||
| 25 | public function index() |
||
| 26 | { |
||
| 27 | $this->load->model('design/layout'); |
||
| 28 | |||
| 29 | if (isset($this->request->get['route'])) { |
||
| 30 | $route = (string)$this->request->get['route']; |
||
| 31 | } else { |
||
| 32 | $route = 'common/home'; |
||
| 33 | } |
||
| 34 | |||
| 35 | $layout_id = 0; |
||
| 36 | |||
| 37 | if ($route == 'product/manufacturer/info' && isset($this->request->get['manufacturer_id'])) { |
||
| 38 | $this->load->model('catalog/manufacturer'); |
||
| 39 | |||
| 40 | $layout_id = $this->model_catalog_manufacturer->getManufacturerLayoutId($this->request->get['manufacturer_id']); |
||
| 41 | } |
||
| 42 | |||
| 43 | if ($route == 'product/category' && isset($this->request->get['path'])) { |
||
| 44 | $this->load->model('catalog/category'); |
||
| 45 | |||
| 46 | $path = explode('_', (string)$this->request->get['path']); |
||
| 47 | |||
| 48 | $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path)); |
||
| 49 | } |
||
| 50 | |||
| 51 | if ($route == 'product/product' && isset($this->request->get['product_id'])) { |
||
| 52 | $this->load->model('catalog/product'); |
||
| 53 | |||
| 54 | $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']); |
||
| 55 | } |
||
| 56 | |||
| 57 | if ($route == 'information/information' && isset($this->request->get['information_id'])) { |
||
| 58 | $this->load->model('catalog/information'); |
||
| 59 | |||
| 60 | $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']); |
||
| 61 | } |
||
| 62 | |||
| 63 | if ($route == 'blog/category' && isset($this->request->get['blog_category_id'])) { |
||
| 64 | $this->load->model('blog/category'); |
||
| 65 | |||
| 66 | $path = explode('_', (string)$this->request->get['blog_category_id']); |
||
| 67 | $layout_id = $this->model_blog_category->getCategoryLayoutId(end($path)); |
||
| 68 | } |
||
| 69 | |||
| 70 | if ($route == 'blog/article' && isset($this->request->get['article_id'])) { |
||
| 71 | $this->load->model('blog/article'); |
||
| 72 | |||
| 73 | $layout_id = $this->model_blog_article->getArticleLayoutId($this->request->get['article_id']); |
||
| 74 | } |
||
| 75 | |||
| 76 | if (!$layout_id) { |
||
| 77 | $layout_id = $this->model_design_layout->getLayout($route); |
||
| 78 | } |
||
| 79 | |||
| 80 | if (!$layout_id) { |
||
| 81 | $layout_id = $this->config->get('config_layout_id'); |
||
| 82 | } |
||
| 83 | |||
| 84 | $this->load->model('extension/module'); |
||
| 85 | |||
| 86 | $data['modules'] = array(); |
||
| 87 | |||
| 88 | $modules = $this->model_design_layout->getLayoutModules($layout_id, 'content_bottom'); |
||
| 89 | |||
| 90 | foreach ($modules as $module) { |
||
| 91 | $part = explode('.', $module['code']); |
||
| 92 | |||
| 93 | if (isset($part[0]) && $this->config->get($part[0] . '_status')) { |
||
| 94 | $module_data = $this->load->controller('extension/module/' . $part[0]); |
||
| 95 | |||
| 96 | if ($module_data) { |
||
| 97 | $data['modules'][] = $module_data; |
||
| 98 | } |
||
| 99 | } |
||
| 100 | |||
| 101 | if (isset($part[1])) { |
||
| 102 | $setting_info = $this->model_extension_module->getModule($part[1]); |
||
| 103 | |||
| 104 | if ($setting_info && $setting_info['status']) { |
||
| 105 | $output = $this->load->controller('extension/module/' . $part[0], $setting_info); |
||
| 106 | |||
| 107 | if ($output) { |
||
| 108 | $data['modules'][] = $output; |
||
| 109 | } |
||
| 110 | } |
||
| 111 | } |
||
| 112 | } |
||
| 113 | |||
| 114 | return $this->load->view('common/content_bottom', $data); |
||
| 115 | } |
||
| 117 |
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.