Completed
Pull Request — master (#2)
by Randall
04:53
created

UseCommand::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 13
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Rawilk\LaravelModules\Commands\Other;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Str;
7
8
class UseCommand extends Command
9
{
10
    /** @var string */
11
    protected $signature = 'module:use
12
                            {module : The name of the module to use in the cli session}';
13
14
    /** @var string */
15
    protected $description = 'Use the specified module in the cli session.';
16
17
    public function handle(): void
18
    {
19
        $module = Str::studly($this->argument('module'));
0 ignored issues
show
Bug introduced by
It seems like $this->argument('module') can also be of type string[]; however, parameter $value of Illuminate\Support\Str::studly() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

19
        $module = Str::studly(/** @scrutinizer ignore-type */ $this->argument('module'));
Loading history...
20
21
        if (! $this->laravel['modules']->has($module)) {
22
            $this->error("Module [{$module}] does not exist!");
23
24
            return;
25
        }
26
27
        $this->laravel['modules']->setUsed($module);
28
29
        $this->info("Module [{$module}] is now being used in the cli session!");
30
    }
31
}
32