PermissionCreate   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 26
ccs 0
cts 11
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 7 1
A handle() 0 9 2
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 PermissionCreate extends Command
10
{
11
    use Commands;
12
13
    protected $signature = 'acl:permission-create {slug}';
14
15
    protected $description = 'Create a new permission';
16
17
    public function handle()
18
    {
19
        if ($this->permissionIsExist()) {
20
            $this->error(sprintf('Permission "%s" already exists!', $this->slug()));
21
22
            return;
23
        }
24
25
        $this->create();
26
    }
27
28
    protected function create()
29
    {
30
        $slug = $this->slug();
31
        $item = Permission::create(compact('slug'));
32
33
        $this->info(sprintf('Permission "%s" created successfully!', $slug));
34
        $this->line($item);
35
    }
36
}
37