Completed
Pull Request — master (#322)
by Mathieu
03:43
created

UseCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getArguments() 0 6 1
A handle() 0 14 2
1
<?php
2
3
namespace Nwidart\Modules\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Str;
7
use Symfony\Component\Console\Input\InputArgument;
8
9
class UseCommand extends Command
10
{
11
    /**
12
     * The console command name.
13
     *
14
     * @var string
15
     */
16
    protected $name = 'module:use';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Use the specified module.';
24
25
    /**
26
     * Execute the console command.
27
     */
28
    public function handle()
29
    {
30
        $module = Str::studly($this->argument('module'));
0 ignored issues
show
Bug introduced by
It seems like $this->argument('module') 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...
31
32
        if (!$this->laravel['modules']->has($module)) {
33
            $this->error("Module [{$module}] does not exists.");
34
35
            return;
36
        }
37
38
        $this->laravel['modules']->setUsed($module);
39
40
        $this->info("Module [{$module}] used successfully.");
41
    }
42
43
    /**
44
     * Get the console command arguments.
45
     *
46
     * @return array
47
     */
48 56
    protected function getArguments()
49
    {
50
        return array(
51 56
            array('module', InputArgument::REQUIRED, 'The name of module will be used.'),
52
        );
53
    }
54
}
55