Completed
Push — master ( a9d673...d0cde4 )
by Arjay
06:58
created

HasRoleDirective::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Yajra\Acl\Directives;
4
5
class HasRoleDirective extends DirectiveAbstract
6
{
7
    /**
8
     * Handle hasRole directive.
9
     *
10
     * @param string|array $roles
11
     * @return bool
12
     */
13
    public function handle($roles)
14
    {
15
        if ($this->auth->check()) {
16
            return $this->auth->user()->hasRole($roles);
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 false;
20
    }
21
}
22