CanAtLeastDirective   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 24
ccs 0
cts 12
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 3
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): bool
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
        }
22
23
        $guest = Role::whereSlug('guest')->first();
24
        if ($guest) {
25
            return $guest->canAtLeast((array) $permissions);
26
        }
27
28
        return false;
29
    }
30
}
31