| Conditions | 3 |
| Paths | 3 |
| Total Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | 6 | public function handle($request, Closure $next, ...$ability) |
|
| 27 | { |
||
| 28 | 6 | $user = auth(config('acl.guard'))->user(); |
|
|
|
|||
| 29 | |||
| 30 | 6 | if (null === $user) { |
|
| 31 | 2 | throw new AuthenticationException(); |
|
| 32 | } |
||
| 33 | |||
| 34 | 4 | if (false === acl($ability)) { |
|
| 35 | 2 | throw new AuthorizationException(); |
|
| 36 | } |
||
| 37 | |||
| 38 | 2 | return $next($request); |
|
| 39 | } |
||
| 40 | } |
||
| 41 |
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: