Commands   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 35
ccs 0
cts 13
cp 0
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A roleIsExist() 0 3 1
A permissionIsDoesntExist() 0 3 1
A roleIsDoesntExist() 0 3 1
A permissionIsExist() 0 3 1
A slug() 0 9 2
1
<?php
2
3
namespace Helldar\Roles\Traits;
4
5
use Helldar\Roles\Models\Permission;
6
use Helldar\Roles\Models\Role;
7
use Illuminate\Support\Str;
8
9
trait Commands
10
{
11
    use Searchable;
12
13
    protected $slug;
14
15
    protected function slug(): string
16
    {
17
        if (is_null($this->slug)) {
18
            $slug = $this->argument('slug');
0 ignored issues
show
Bug introduced by
It seems like argument() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
            /** @scrutinizer ignore-call */ 
19
            $slug = $this->argument('slug');
Loading history...
19
20
            $this->slug = Str::slug($slug, '_');
21
        }
22
23
        return $this->slug;
24
    }
25
26
    protected function roleIsExist(): bool
27
    {
28
        return $this->searchExist(Role::class, $this->slug());
29
    }
30
31
    protected function roleIsDoesntExist(): bool
32
    {
33
        return ! $this->roleIsExist();
34
    }
35
36
    protected function permissionIsExist(): bool
37
    {
38
        return $this->searchExist(Permission::class, $this->slug());
39
    }
40
41
    protected function permissionIsDoesntExist(): bool
42
    {
43
        return ! $this->permissionIsExist();
44
    }
45
}
46