Passed
Pull Request — master (#58)
by Keoghan
04:15
created

XdebugOff   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\Models\Site;
8
use App\Support\Php\Xdebug;
9
10
class XdebugOff extends BaseCommand
11
{
12
    /**
13
     * The signature of the command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'php:xdebug-off {php_version?}';
18
19
    /**
20
     * The description of the command.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Turn Xdebug off, optionally for a specific PHP version';
25
26
    /**
27
     * Execute the console command.
28
     *
29
     * @return void
30
     */
31 3
    public function handle(): void
32
    {
33 3
        $phpVersion = null;
34
35 3
        if ($this->argument('php_version')
36 3
            && ! ($phpVersion = PhpVersion::findByDirtyVersionNumber($this->argument('php_version')))
37
        ) {
38 1
            $this->error('Invalid PHP version provided');
39
40 1
            return;
41
        }
42
43 2
        app(Xdebug::class)->turnOff($phpVersion);
44
45 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...
46 2
    }
47
}
48