UseCommand::fire()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 0
1
<?php
2
3
namespace Consigliere\Components\Commands;
4
5
use Illuminate\Console\Command as ComponentCommand;
6
use Illuminate\Support\Str;
7
use Symfony\Component\Console\Input\InputArgument;
8
9
class UseCommand extends ComponentCommand
10
{
11
    /**
12
     * The console command name.
13
     *
14
     * @var string
15
     */
16
    protected $name = 'component:use';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Use the specified component.';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @return mixed
29
     */
30
    public function fire()
31
    {
32
        $component = Str::studly($this->argument('component'));
0 ignored issues
show
Bug introduced by
It seems like $this->argument('component') targeting Illuminate\Console\Command::argument() can also be of type array; however, Illuminate\Support\Str::studly() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
33
34
        if (!$this->laravel['components']->has($component)) {
35
            $this->error("Component [{$component}] does not exists.");
36
37
            return;
38
        }
39
40
        $this->laravel['components']->setUsed($component);
41
42
        $this->info("Component [{$component}] used successfully.");
43
    }
44
45
    /**
46
     * Get the console command arguments.
47
     *
48
     * @return array
49
     */
50
    protected function getArguments()
51
    {
52
        return [
53
            ['component', InputArgument::REQUIRED, 'The name of component will be used.'],
54
        ];
55
    }
56
}
57