RoleCreate   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 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 RoleCreate extends Command
10
{
11
    use Commands;
12
13
    protected $signature = 'acl:role-create {slug}';
14
15
    protected $description = 'Create a new role';
16
17
    public function handle()
18
    {
19
        if ($this->roleIsExist()) {
20
            $this->error(sprintf('Role "%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
32
        $item = Role::create(compact('slug'));
33
34
        $this->info(sprintf('Role "%s" created successfully!', $slug));
35
        $this->line($item);
36
    }
37
}
38