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