RoleDirective   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 17
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 2
1
<?php
2
3
namespace Yajra\Acl\Directives;
4
5
class RoleDirective extends DirectiveAbstract
6
{
7
    /**
8
     * Is Role blade directive compiler.
9
     *
10
     * @param  string|array  $role
11
     * @return bool
12
     */
13
    public function handle($role): bool
14
    {
15
        if ($this->auth->check()) {
16
            return $this->auth->user()->hasRole($role);
0 ignored issues
show
Bug introduced by
The method hasRole() does not seem to exist on object<Illuminate\Contracts\Auth\Authenticatable>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
17
        }
18
19
        return $role === 'guest';
20
    }
21
}
22