Conditions | 4 |
Paths | 4 |
Total Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
18 | public function handle(Request $request, Closure $next, $permissions) |
||
19 | { |
||
20 | $abilities = is_array($permissions) ? $permissions : explode(',', $permissions); |
||
21 | |||
22 | if (!auth()->check() || !auth()->user()->canAtLeast($abilities)) { |
||
23 | abort(403, 'You are not allowed to view this content!'); |
||
24 | } |
||
25 | |||
26 | return $next($request); |
||
27 | } |
||
28 | } |
||
29 |
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: