Passed
Push — master ( dcf026...963312 )
by Caen
03:39 queued 14s
created

PublishConfigsCommand::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 12
nc 1
nop 0
dl 0
loc 19
rs 9.8666
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Console\Commands;
6
7
use Hyde\Console\Concerns\Command;
8
use Hyde\Hyde;
9
use Illuminate\Support\Facades\Artisan;
10
11
/**
12
 * Publish the Hyde Config Files.
13
 *
14
 * @see \Hyde\Framework\Testing\Feature\Commands\UpdateConfigsCommandTest
15
 */
16
class PublishConfigsCommand extends Command
17
{
18
    /** @var string */
19
    protected $signature = 'publish:configs';
20
21
    /** @var string */
22
    protected $description = 'Publish the default configuration files';
23
24
    public function handle(): int
25
    {
26
        $options = [
27
            'All configs',
28
            '<comment>hyde-configs</comment>: Main configuration files',
29
            '<comment>support-configs</comment>: Laravel and package configuration files',
30
        ];
31
        $selection = $this->choice('Which configuration files do you want to publish?', $options, 'All configs');
32
33
        $tag = $this->parseTagFromSelection($selection, $options);
0 ignored issues
show
Bug introduced by
It seems like $selection can also be of type array; however, parameter $selection of Hyde\Console\Commands\Pu...parseTagFromSelection() 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

33
        $tag = $this->parseTagFromSelection(/** @scrutinizer ignore-type */ $selection, $options);
Loading history...
34
35
        Artisan::call('vendor:publish', [
36
            '--tag' => $tag,
37
            '--force' => true,
38
        ], $this->output);
39
40
        $this->infoComment(sprintf('Published config files to [%s]', Hyde::path('config')));
41
42
        return Command::SUCCESS;
43
    }
44
45
    protected function parseTagFromSelection(string $selection, array $options): string
46
    {
47
        $tags = ['configs', 'hyde-configs', 'support-configs'];
48
49
        return $tags[array_search($selection, $options)];
50
    }
51
}
52