Open   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 14
dl 0
loc 37
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 16 3
1
<?php
2
3
namespace App\Commands\Php;
4
5
use App\Commands\BaseCommand;
6
use App\Models\PhpVersion;
7
use App\Models\Site;
8
9
class Open extends BaseCommand
10
{
11
    /**
12
     * The signature of the command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'php:open {run?} {--p|php-version=}';
17
18
    /**
19
     * The description of the command.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Open PHP cli';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @return void
29
     */
30
    public function handle(): void
31
    {
32
        if ($version = (string) $this->option('php-version')) {
33
            $version = PhpVersion::findByDirtyVersionNumber($version);
34
        } else {
35
            $version = optional(Site::resolveFromPathOrCurrentWorkingDirectory())->php_version
36
                ?: PhpVersion::defaultVersion();
37
        }
38
39
        $this->info("PHP Version: {$version->version_number}");
40
41
        $this->dockerCompose
42
            ->runContainer("php_cli_{$version->safe}")
43
            ->bash((string) $this->argument('run'))
44
            ->doNotTimeout()
45
            ->perform();
46
    }
47
}
48