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

CanAtLeastDirective::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 13
ccs 0
cts 12
cp 0
rs 9.4285
cc 3
eloc 8
nc 3
nop 1
crap 12
1
<?php
2
3
namespace Yajra\Acl\Directives;
4
5
use Yajra\Acl\Models\Role;
6
7
class CanAtLeastDirective extends DirectiveAbstract
8
{
9
    /**
10
     * Can at least blade directive compiler.
11
     *
12
     * @param string|array $permissions
13
     * @return bool
14
     * @throws \Exception
15
     * @throws \Throwable
16
     */
17
    public function handle($permissions)
18
    {
19
        if ($this->auth->check()) {
20
            return $this->auth->user()->canAtLeast((array) $permissions);
0 ignored issues
show
Bug introduced by
The method canAtLeast() 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...
21
        } else {
22
            $guest = Role::whereSlug('guest')->first();
23
            if ($guest) {
24
                return $guest->canAtLeast((array) $permissions);
25
            }
26
        }
27
28
        return false;
29
    }
30
}
31