| Conditions | 11 |
| Paths | 392 |
| Total Lines | 56 |
| Code Lines | 26 |
| 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 |
||
| 157 | public function run() |
||
| 158 | { |
||
| 159 | /* |
||
| 160 | * Key value pairs builder: |
||
| 161 | * Searches for the pattern /var1/value1/var2/value2 and converts it to var1 => value1, var2 => value2 |
||
| 162 | */ |
||
| 163 | if (array_key_exists('params', $_GET)) |
||
| 164 | { |
||
| 165 | $keypairs = $this->parseRequestParameters($_GET["params"]); |
||
| 166 | unset($_GET["params"]); |
||
| 167 | $_GET = array_merge($_GET, $keypairs); |
||
| 168 | } |
||
| 169 | |||
| 170 | /* |
||
| 171 | * Route builder: |
||
| 172 | * The route is built by default from the URL as follow |
||
| 173 | * www.example.com/module/controller/view |
||
| 174 | */ |
||
| 175 | |||
| 176 | $module = (is_null($this->identifiers["module"]) || empty($this->identifiers["module"])) |
||
| 177 | ? $this->routes["defaults"]["module"] : $this->identifiers["module"]; |
||
| 178 | |||
| 179 | if (!array_key_exists($module, $this->routes)) |
||
| 180 | throw new Exception\ModuleNotFoundException("The key '$module' does not exists in routes!"); |
||
| 181 | |||
| 182 | $controller = (is_null($this->identifiers["controller"]) || empty($this->identifiers["controller"])) |
||
| 183 | ? $this->routes[$module]["controller"] : $this->identifiers["controller"]; |
||
| 184 | |||
| 185 | $view = (is_null($this->identifiers["view"]) || empty($this->identifiers["view"])) |
||
| 186 | ? $this->routes[$module]["view"] : $this->identifiers["view"]; |
||
| 187 | |||
| 188 | $fqn_controller = '\\' . $module . "\Controller\\" . $controller; |
||
| 189 | |||
| 190 | if (class_exists($fqn_controller)) |
||
| 191 | { |
||
| 192 | try { |
||
| 193 | $this->controller = new $fqn_controller($view, $this->basePath); |
||
| 194 | } |
||
| 195 | catch (Exception\MethodNotFoundException $e) |
||
| 196 | { |
||
| 197 | # change context, in terms of Router MethodNotFoundException is a PageNotfoundException |
||
| 198 | throw new Exception\PageNotFoundException($e->getMessage(), $e->getCode(), $e); |
||
| 199 | } |
||
| 200 | |||
| 201 | # in controller terms, a view is a method |
||
| 202 | $this->controller->setMethod($view); |
||
| 203 | |||
| 204 | $this->controller->createModuleInstance($module); |
||
| 205 | $this->controller->getModule()->setModulePath($this->modulePath); |
||
| 206 | $this->controller->getModule()->setControllerPath('source/Controller'); |
||
| 207 | $this->controller->getModule()->setViewPath('source/view'); |
||
| 208 | |||
| 209 | $this->controller->execute(); |
||
| 210 | } |
||
| 211 | else |
||
| 212 | throw new Exception\ControllerNotFoundException("The control class '$fqn_controller' does not exists!"); |
||
| 213 | } |
||
| 292 | } |
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