UseSet   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 20
dl 0
loc 49
ccs 0
cts 16
cp 0
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 28 4
1
<?php
2
3
namespace App\Commands\Images;
4
5
use App\Commands\BaseCommand;
6
use App\Models\Setting;
7
use App\Support\Contracts\ImageSetRepository;
8
use Illuminate\Support\Facades\Artisan;
9
10
class UseSet extends BaseCommand
11
{
12
    /**
13
     * The signature of the command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'images:set {--show}';
18
19
    /**
20
     * The description of the command.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Change the set of container images use';
25
26
    /**
27
     * Execute the console command.
28
     *
29
     * @return void
30
     */
31
    public function handle(): void
32
    {
33
        $current = $this->porter->getDockerImageSet()->getName();
34
35
        if ($this->option('show')) {
36
            $this->info('The current image set is: '.$current);
37
38
            return;
39
        }
40
41
        $sets = app(ImageSetRepository::class)
42
            ->availableImageSets()
43
            ->mapWithKeys(function ($set) use ($current) {
44
                return [$set => $set.($current == $set ? ' (current)' : '')];
45
            })->toArray();
46
47
        $option = $this->menu(
48
            'Available Image Sets',
49
            $sets
50
        )->open();
51
52
        if (!$option) {
53
            return;
54
        }
55
56
        Setting::updateOrCreate('docker_image_set', $option);
57
58
        Artisan::call('make-files');
59
    }
60
}
61