Passed
Pull Request — master (#58)
by Keoghan
05:14 queued 01:03
created

XdebugOn   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 10
dl 0
loc 36
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 15 4
1
<?php
2
3
namespace App\Commands\Php;
4
5
use App\Commands\BaseCommand;
6
use App\Models\PhpVersion;
7
use App\Support\Php\Xdebug;
8
9
class XdebugOn extends BaseCommand
10
{
11
    /**
12
     * The signature of the command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'php:xdebug-on {php_version?}';
17
18
    /**
19
     * The description of the command.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Turn Xdebug on, optionally for a specific PHP version';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @return void
29
     */
30 3
    public function handle(): void
31
    {
32 3
        $phpVersion = null;
33
34 3
        if ($this->argument('php_version')
35 3
            && !($phpVersion = PhpVersion::findByDirtyVersionNumber($this->argument('php_version')))
36
        ) {
37 1
            $this->error('Invalid PHP version provided');
38
39 1
            return;
40
        }
41
42 2
        app(Xdebug::class)->turnOn($phpVersion);
43
44 2
        $this->porter->restart($phpVersion ? $phpVersion->fpm_name : null);
0 ignored issues
show
introduced by
$phpVersion is of type null, thus it always evaluated to false.
Loading history...
45 2
    }
46
}
47