Issues (197)

src/Commands/UseCommand.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Salah3id\Domains\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 = 'domain:use';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Use the specified domain.';
24
25
    /**
26
     * Execute the console command.
27
     */
28
    public function handle(): int
29
    {
30
        $domain = Str::studly($this->argument('domain'));
0 ignored issues
show
It seems like $this->argument('domain') can also be of type array; 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

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