ListVersions::handle()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 17
ccs 0
cts 10
cp 0
rs 9.9332
cc 3
nc 1
nop 0
crap 12
1
<?php
2
3
namespace App\Commands\Php;
4
5
use App\Commands\BaseCommand;
6
use App\Models\PhpVersion;
7
8
class ListVersions extends BaseCommand
9
{
10
    /**
11
     * The signature of the command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'php:list';
16
17
    /**
18
     * The description of the command.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'List available sites';
23
24
    /**
25
     * Execute the console command.
26
     *
27
     * @return void
28
     */
29
    public function handle(): void
30
    {
31
        $headers = ['Version Number', 'Default', 'Active'];
32
33
        $activeVersions = PhpVersion::active()->get();
34
35
        $versions = PhpVersion::orderBy('name', 'asc')
36
            ->get()
37
            ->map(function ($version) use ($activeVersions) {
38
                return [
39
                    $version->version_number,
40
                    $version->default ? 'yes' : '-',
41
                    $activeVersions->contains($version) ? 'yes' : '-',
42
                ];
43
            });
44
45
        $this->table($headers, $versions);
46
    }
47
}
48