Completed
Push — master ( 4fafa1...e65f27 )
by Nicolas
12:12
created

src/Commands/UseCommand.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 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
It seems like $this->argument('module') targeting Illuminate\Console\Command::argument() can also be of type array or null; 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 120
    protected function getArguments()
49
    {
50
        return [
51 120
            ['module', InputArgument::REQUIRED, 'The name of module will be used.'],
52
        ];
53
    }
54
}
55