| Conditions | 7 |
| Paths | 5 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 7.392 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | 4 | public function handle(Request $request, Closure $next) |
|
| 31 | { |
||
| 32 | // If the request URL is ignored from localization. |
||
| 33 | 4 | if ($this->shouldIgnore($request)) return $next($request); |
|
| 34 | |||
| 35 | 4 | $segment = $request->segment(1, null); |
|
| 36 | |||
| 37 | 4 | if ($this->localization->isLocaleSupported($segment)) |
|
| 38 | return $next($request)->withCookie(cookie()->forever('locale', $segment)); |
||
|
|
|||
| 39 | |||
| 40 | 4 | $locale = $request->cookie('locale', null); |
|
| 41 | |||
| 42 | 4 | if ($this->localization->isLocaleSupported($locale) && $locale !== null && ! $this->isDefaultLocaleHidden($locale)) { |
|
| 43 | 4 | if ( ! is_null($redirect = $this->getLocalizedRedirect($locale))) |
|
| 44 | 4 | return $redirect->withCookie(cookie()->forever('locale', $locale)); |
|
| 45 | } |
||
| 46 | |||
| 47 | return $next($request); |
||
| 48 | } |
||
| 49 | } |
||
| 50 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: