GenerateTagGroup::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 3
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 10
1
<?php
2
3
namespace Conner\Tagging\Console\Commands;
4
5
use Conner\Tagging\TaggingUtility;
6
use Illuminate\Console\Command;
7
use Symfony\Component\Console\Input\InputArgument;
8
9
class GenerateTagGroup extends Command
10
{
11
    protected $name = 'tagging:create-group';
12
13
    protected $signature = 'tagging:create-group {group}';
14
15
    protected $description = 'Create a laravel tag group';
16
17
    public function handle()
18
    {
19
        $groupName = $this->argument('group');
20
21
        $tagGroupModel = TaggingUtility::tagGroupModelString();
22
23
        $tagGroup = new $tagGroupModel;
24
        $tagGroup->name = $groupName;
25
        $tagGroup->slug = TaggingUtility::normalize($groupName);
26
27
        $tagGroup->save();
28
29
        $this->info('Created tag group: '.$groupName);
30
    }
31
32
    protected function getArguments()
33
    {
34
        return [
35
            ['group', InputArgument::REQUIRED, 'Name of the group to create.'],
36
        ];
37
    }
38
}
39