Permissions   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 22
ccs 5
cts 5
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 3
1
<?php
2
3
namespace Helldar\Roles\Http\Middleware;
4
5
use Closure;
6
use Helldar\Roles\Exceptions\Http\PermissionAccessIsDeniedHttpException;
7
8
class Permissions extends BaseMiddleware
9
{
10
    /**
11
     * Checks the entry of all of the specified permissions.
12
     *
13
     * @param  \Illuminate\Http\Request  $request
14
     * @param  Closure  $next
15
     * @param  string  ...$permissions
16
     *
17
     * @throws \Helldar\Roles\Exceptions\Http\PermissionAccessIsDeniedHttpException
18
     *
19
     * @return mixed
20
     */
21 30
    public function handle($request, Closure $next, ...$permissions)
22
    {
23 30
        $this->check();
24
25 18
        if ($this->hasRoot($request) || $request->user()->hasPermissions($permissions)) {
26 12
            return $next($request);
27
        }
28
29 6
        throw new PermissionAccessIsDeniedHttpException();
30
    }
31
}
32