PermissionDelete::remove()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
ccs 0
cts 4
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Helldar\Roles\Console;
4
5
use Helldar\Roles\Models\Permission;
6
use Helldar\Roles\Traits\Commands;
7
use Illuminate\Console\Command;
8
9
class PermissionDelete extends Command
10
{
11
    use Commands;
12
13
    protected $signature = 'acl:permission-delete {slug|ID or permission slug}';
14
15
    protected $description = 'Deleting a permission';
16
17
    public function handle()
18
    {
19
        if ($this->permissionIsDoesntExist()) {
20
            $this->error(sprintf('Permission "%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(Permission::class, $slug)->delete();
33
34
        $this->info(sprintf('Permission "%s" successfully deleted!', $slug));
35
    }
36
}
37