Completed
Push — master ( 932456...5099d4 )
by
unknown
9s
created

CreateCategory::getArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Fenos\Notifynder\Artisan;
4
5
use Fenos\Notifynder\Contracts\NotifynderCategory;
6
use Illuminate\Console\Command;
7
use Symfony\Component\Console\Input\InputArgument;
8
9
class CreateCategory extends Command
10
{
11
    /**
12
     * The console command name.
13
     *
14
     * @var string
15
     */
16
    protected $name = 'notifynder:create:category';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Create and store a new notifynder category';
24
25
    /**
26
     * @var \\Fenos\Notifynder\Contracts\NotifynderCategory
27
     */
28
    private $notifynderCategory;
29
30
    /**
31
     * Create a new command instance.
32
     *
33
     * @param  NotifynderCategory                    $notifynderCategory
34
     * @return \Fenos\Notifynder\Artisan\CreateCategory
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(NotifynderCategory $notifynderCategory)
37
    {
38
        parent::__construct();
39
40
        $this->notifynderCategory = $notifynderCategory;
0 ignored issues
show
Documentation Bug introduced by
It seems like $notifynderCategory of type object<Fenos\Notifynder\...cts\NotifynderCategory> is incompatible with the declared type object<\Fenos\Notifynder...cts\NotifynderCategory> of property $notifynderCategory.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
41
    }
42
43
    /**
44
     * Execute the console command.
45
     *
46
     * @return mixed
47
     */
48
    public function fire()
49
    {
50
        $name = $this->argument('name');
51
        $text = $this->argument('text');
52
53
        $createCategory = $this->notifynderCategory->add($name, $text);
54
55
        if (! $createCategory) {
56
            $this->error('The category has been not created');
57
58
            return false;
59
        }
60
61
        $this->info("Category $createCategory->name has been created");
62
    }
63
64
    /**
65
     * Get the console command arguments.
66
     *
67
     * @return array
68
     */
69
    protected function getArguments()
70
    {
71
        return [
72
            ['name', InputArgument::REQUIRED, 'Name of the category.'],
73
            ['text', InputArgument::REQUIRED, 'Text of the category.'],
74
        ];
75
    }
76
}
77