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

src/Notifynder/Artisan/CreateCategory.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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