UseCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 48
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fire() 0 14 2
A getArguments() 0 6 1
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