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

XdebugOff::handle()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
cc 4
nc 2
nop 0
crap 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 XdebugOff extends BaseCommand
10
{
11
    /**
12
     * The signature of the command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'php:xdebug-off {php_version?}';
17
18
    /**
19
     * The description of the command.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Turn Xdebug off, 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)->turnOff($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