Commands::slug()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 9
ccs 0
cts 5
cp 0
crap 6
rs 10
c 0
b 0
f 0
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