| Conditions | 18 |
| Paths | 360 |
| Total Lines | 56 |
| Code Lines | 43 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 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 |
||
| 13 | public function indexAction() { |
||
| 14 | $args = func_get_args(); |
||
| 15 | $category = null; |
||
| 16 | $material = null; |
||
| 17 | $path = trim(implode('/', $args)); |
||
| 18 | if (is_numeric($path)) { |
||
| 19 | $material = Materials\Material::get([['id', (int) $path], ['date_publish', null, 'IS NOT']]); |
||
| 20 | } |
||
| 21 | if (!$material && $args) { |
||
| 22 | foreach ($args as $key => $alias) { |
||
| 23 | $nextCategory = Materials\Category::get([['parent_id', $category ? $category->id : 0], ['alias', $alias]]); |
||
| 24 | if (!$nextCategory) { |
||
| 25 | break; |
||
| 26 | } |
||
| 27 | $category = $nextCategory; |
||
| 28 | } |
||
| 29 | } |
||
| 30 | if (!$material && $path) { |
||
| 31 | if ($category) { |
||
| 32 | $where = [ |
||
| 33 | ['tree_path', $category->tree_path . $category->id . '/%', 'LIKE'], |
||
| 34 | ['alias', $args[count($args) - 1]], |
||
| 35 | ['date_publish', null, 'IS NOT'] |
||
| 36 | ]; |
||
| 37 | } else { |
||
| 38 | $where = [['alias', $path], ['date_publish', null, 'IS NOT']]; |
||
| 39 | } |
||
| 40 | $material = Materials\Material::get($where); |
||
| 41 | if (!$material) { |
||
| 42 | if ($category) { |
||
| 43 | $where = [ |
||
| 44 | ['category_id', $category->id], |
||
| 45 | ['id', (int) $args[count($args) - 1]], |
||
| 46 | ['date_publish', null, 'IS NOT'] |
||
| 47 | ]; |
||
| 48 | } else { |
||
| 49 | $where = [['alias', $path], ['date_publish', null, 'IS NOT']]; |
||
| 50 | } |
||
| 51 | $material = Materials\Material::get($where); |
||
| 52 | } |
||
| 53 | if (!$material) { |
||
| 54 | $category = Materials\Category::get($path, 'alias'); |
||
| 55 | if ($category) { |
||
| 56 | $this->categoryAction($category->id); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } elseif (!$material) { |
||
| 60 | $material = Materials\Material::get(1, 'default'); |
||
| 61 | } |
||
| 62 | if ($material) { |
||
| 63 | $this->viewAction($material->id); |
||
| 64 | } elseif (!$category && !$material) { |
||
| 65 | Tools::header('404'); |
||
| 66 | $this->view->page([ |
||
| 67 | 'content' => '404', |
||
| 68 | 'data' => ['text' => 'Такой страницы не найдено'] |
||
| 69 | ]); |
||
| 160 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths