| Conditions | 15 |
| Paths | 39 |
| Total Lines | 60 |
| Code Lines | 27 |
| 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 |
||
| 31 | public function handle($request, Closure $next) |
||
| 32 | { |
||
| 33 | $this->app = app(); |
||
| 34 | $this->config = $this->app['config']; |
||
| 35 | |||
| 36 | if ($this->isAvailableMethod($request) && $this->isAvailableCheckPath($request)) { |
||
| 37 | |||
| 38 | $path = $request->path(); |
||
| 39 | |||
| 40 | // Check lovalization support |
||
| 41 | if ($this->useLocalization = $this->config->get('url-aliases.use_localization') && $this->isAvailableLocalizationPath($request)) { |
||
| 42 | $localization = $this->app->make(UrlAliasLocalization::class); |
||
| 43 | |||
| 44 | $localizationResult = $localization->prepareLocalizePath($request->path()); |
||
| 45 | |||
| 46 | if (isset($localizationResult['redirect'])) { |
||
| 47 | $params = count($request->all()) ? '?' . http_build_query($request->all()) : ''; |
||
| 48 | return redirect()->to($localizationResult['redirect'] . $params, 301); // hide default locale in URL |
||
| 49 | } elseif (isset($localizationResult['path'])) { |
||
| 50 | $path = $localizationResult['path']; |
||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | $urlModels = $this->getByPath($path); |
||
| 55 | |||
| 56 | // If visited source - system path |
||
| 57 | if ($urlModel = $urlModels->where('source', $path)->where('locale', $this->app->getLocale())->first()/* && $path != 'de'*/) { |
||
| 58 | |||
| 59 | $redirectStatus = $this->config->get('url-aliases.redirect_for_system_path', 301) == 301 ? 301 : 302; |
||
| 60 | |||
| 61 | // Redirect to alias path |
||
| 62 | $params = count($request->all()) ? '?' . http_build_query($request->all()) : ''; |
||
| 63 | |||
| 64 | if ($this->useLocalization) { |
||
| 65 | return redirect()->to(url($urlModel->localeAlias) . '/' . $params, $redirectStatus); |
||
| 66 | } |
||
| 67 | |||
| 68 | return redirect()->to(url($urlModel->alias) . '/' . $params, $redirectStatus); |
||
| 69 | |||
| 70 | // If visited alias |
||
| 71 | } elseif ($urlModel = $urlModels->where('alias', $path)->where('locale', $this->app->getLocale())->first()) { |
||
| 72 | |||
| 73 | // Redirect to source |
||
| 74 | if ($redirect = $this->isTypeRedirect($urlModel)) { |
||
| 75 | return $redirect; |
||
| 76 | } |
||
| 77 | |||
| 78 | // Make new request |
||
| 79 | $newRequest = $this->makeNewRequest($request, $urlModel); |
||
| 80 | |||
| 81 | return $next($newRequest); |
||
| 82 | |||
| 83 | // Check if isset facet in current url and find aliased path without facet |
||
| 84 | } elseif ($customReturn = $this->customize($request, $next)) { |
||
| 85 | |||
| 86 | return $customReturn; |
||
| 87 | } |
||
| 88 | } |
||
| 89 | |||
| 90 | return $next($request); |
||
| 91 | } |
||
| 190 |
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