RoleDelete   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
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 26
ccs 0
cts 10
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A remove() 0 7 1
A handle() 0 9 2
1
<?php
2
3
namespace Helldar\Roles\Console;
4
5
use Helldar\Roles\Models\Role;
6
use Helldar\Roles\Traits\Commands;
7
use Illuminate\Console\Command;
8
9
class RoleDelete extends Command
10
{
11
    use Commands;
12
13
    protected $signature = 'acl:role-delete {slug|ID or role slug}';
14
15
    protected $description = 'Deleting a role';
16
17
    public function handle()
18
    {
19
        if ($this->roleIsDoesntExist()) {
20
            $this->error(sprintf('Role "%s" doesn\'t exists!', $this->slug()));
21
22
            return;
23
        }
24
25
        $this->remove();
26
    }
27
28
    protected function remove()
29
    {
30
        $slug = $this->slug();
31
32
        $this->searchBuilder(Role::class, $slug)->delete();
33
34
        $this->info(sprintf('Role "%s" successfully deleted!', $slug));
35
    }
36
}
37