| Conditions | 10 |
| Paths | 129 |
| Total Lines | 54 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | 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 |
||
| 42 | public function getNestedController() |
||
| 43 | { |
||
| 44 | $request = $this->getRequest(); |
||
| 45 | |||
| 46 | if (!$URLSegment = $request->param('URLSegment')) { |
||
| 47 | throw new Exception('ModelAsController->getNestedController(): was not passed a URLSegment value.'); |
||
| 48 | } |
||
| 49 | |||
| 50 | // Find page by link, regardless of current locale settings |
||
| 51 | if (class_exists('Translatable')) { |
||
| 52 | Translatable::disable_locale_filter(); |
||
| 53 | } |
||
| 54 | |||
| 55 | // Select child page |
||
| 56 | $sitetree_conditions = ["URLSegment" => rawurlencode($URLSegment)]; |
||
| 57 | $cat_conditions = $sitetree_conditions; |
||
| 58 | $product_conditions = $sitetree_conditions; |
||
| 59 | |||
| 60 | if (SiteTree::config()->get('nested_urls')) { |
||
| 61 | $sitetree_conditions['ParentID'] = 0; |
||
| 62 | } |
||
| 63 | |||
| 64 | $cat_conditions['ParentID'] = 0; |
||
| 65 | |||
| 66 | $object = SiteTree::get() |
||
| 67 | ->filter($sitetree_conditions) |
||
| 68 | ->first(); |
||
| 69 | |||
| 70 | if (!$object) { |
||
| 71 | $object = CatalogueCategory::get() |
||
| 72 | ->filter($cat_conditions) |
||
| 73 | ->first(); |
||
| 74 | } |
||
| 75 | |||
| 76 | // Check translation module |
||
| 77 | // @todo Refactor out module specific code |
||
| 78 | if (class_exists('Translatable')) { |
||
| 79 | Translatable::enable_locale_filter(); |
||
| 80 | } |
||
| 81 | |||
| 82 | if (!$object) { |
||
| 83 | $this->httpError(404, 'The requested page could not be found.'); |
||
| 84 | } |
||
| 85 | |||
| 86 | // Enforce current locale setting to the loaded SiteTree object |
||
| 87 | if (class_exists('Translatable') && $object->Locale) { |
||
| 88 | Translatable::set_current_locale($object->Locale); |
||
| 89 | } |
||
| 90 | |||
| 91 | if (isset($_REQUEST['debug'])) { |
||
| 92 | Debug::message("Using record #$object->ID of type " . get_class($object) . " with link {$sitetree->Link()}"); |
||
| 93 | } |
||
| 94 | |||
| 95 | return self::controller_for_object($object, $this->getRequest()->param('Action')); |
||
| 96 | } |
||
| 97 | } |
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