Completed
Push — master ( 67516c...274239 )
by Arjay
06:05
created

RoleDirective::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 0
cts 11
cp 0
rs 9.4285
cc 3
eloc 7
nc 3
nop 1
crap 12
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 $role
11
     * @return bool
12
     */
13
    public function handle($role)
14
    {
15
        if ($this->auth->check()) {
16
            return $this->auth->user()->isRole($role);
0 ignored issues
show
Bug introduced by
The method isRole() 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
        } else {
18
            if ($role === 'guest') {
19
                return true;
20
            }
21
        }
22
23
        return false;
24
    }
25
}
26