| Conditions | 7 |
| Paths | 5 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 7.392 |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | 6 | public function handle(Request $request, Closure $next) |
|
| 32 | { |
||
| 33 | // If the request URL is ignored from localization. |
||
| 34 | 6 | if ($this->shouldIgnore($request) || class_basename($next($request)) === 'StreamedResponse') return $next($request); |
|
| 35 | |||
| 36 | 6 | $segment = $request->segment(1, null); |
|
| 37 | |||
| 38 | 6 | if ($this->localization->isLocaleSupported($segment)) |
|
| 39 | return $next($request)->withCookie(cookie()->forever('locale', $segment)); |
||
|
|
|||
| 40 | |||
| 41 | 6 | $locale = $request->cookie('locale', null); |
|
| 42 | |||
| 43 | 6 | if ($locale !== null && ! $this->isDefaultLocaleHidden($locale)) { |
|
| 44 | 6 | if ( ! is_null($redirect = $this->getLocalizedRedirect($locale))) |
|
| 45 | 6 | return $redirect->withCookie(cookie()->forever('locale', $segment)); |
|
| 46 | } |
||
| 47 | |||
| 48 | return $next($request); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |
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: