Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
26 | public function handle($request, Closure $next) |
||
27 | { |
||
28 | |||
29 | if ($this->authService->guest()) { |
||
30 | if ($request->wantsJson()) { |
||
31 | $headers = [ |
||
32 | 'WWW-Authenticate' => 'Auth', |
||
33 | ]; |
||
34 | return response('Unauthorized.', 401, $headers); |
||
35 | } else { |
||
36 | return $this->redirect(); |
||
37 | } |
||
38 | } |
||
39 | |||
40 | return $next($request); |
||
41 | } |
||
42 | |||
50 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.