Completed
Push — master ( 9abbc7...a687e5 )
by Fabrizio
03:03
created

CreateGroup   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 4
Bugs 3 Features 1
Metric Value
wmc 4
c 4
b 3
f 1
lcom 1
cbo 2
dl 0
loc 62
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A fire() 0 11 2
A getArguments() 0 6 1
1
<?php
2
3
namespace Fenos\Notifynder\Artisan;
4
5
use Fenos\Notifynder\Contracts\NotifynderGroup;
6
use Illuminate\Console\Command;
7
use Symfony\Component\Console\Input\InputArgument;
8
9
class CreateGroup extends Command
10
{
11
    /**
12
     * The console command name.
13
     *
14
     * @var string
15
     */
16
    protected $name = 'notifynder:create:group';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Store a new notifynder group in the DB.';
24
25
    /**
26
     * @var NotifynderGroup
27
     */
28
    private $notifynderGroup;
29
30
    /**
31
     * Create a new command instance.
32
     *
33
     * @param  NotifynderGroup                    $notifynderGroup
34
     * @return \Fenos\Notifynder\Artisan\CreateGroup
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
35
     */
36
    public function __construct(NotifynderGroup $notifynderGroup)
37
    {
38
        parent::__construct();
39
        $this->notifynderGroup = $notifynderGroup;
40
    }
41
42
    /**
43
     * Execute the console command.
44
     *
45
     * @return mixed
46
     */
47
    public function fire()
48
    {
49
        $nameGroup = $this->argument('name');
50
51
        if (! $this->notifynderGroup->addGroup($nameGroup)) {
52
            $this->error('The name must be a string with dots as namespaces');
53
54
            return false;
55
        }
56
        $this->info("Group {$nameGroup} has Been created");
57
    }
58
59
    /**
60
     * Get the console command arguments.
61
     *
62
     * @return array
63
     */
64
    protected function getArguments()
65
    {
66
        return [
67
            ['name', InputArgument::REQUIRED, 'user.post.add'],
68
        ];
69
    }
70
}
71