Issues (17)

src/Traits/Commands.php (1 issue)

Labels
Severity
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
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