Passed
Push — master ( caf93d...cf5135 )
by Keoghan
06:09
created

XdebugStatus   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 38
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 15 3
1
<?php
2
3
namespace App\Commands\Php;
4
5
use App\Commands\BaseCommand;
6
use App\Support\XDebug\XDebug;
7
8
class XdebugStatus extends BaseCommand
9
{
10
    /**
11
     * The signature of the command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'php:xdebug {status}';
16
17
    /**
18
     * The description of the command.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Set XDebug status On/Off';
23
24
    /**
25
     * Execute the console command.
26
     *
27
     * @throws \Exception
28
     *
29
     * @return void
30
     */
31
    public function handle(): void
32
    {
33
        $status = strtolower(/** @scrutinizer ignore-type */ $this->argument('status'));
34
35
        if (!in_array($status, ['on', 'off'])) {
36
            throw new \Exception('Xdebug can only be turned on or off.');
37
        }
38
39
        if ($status === 'on') {
40
            app(XDebug::class)->turnOn();
41
42
            return;
43
        }
44
45
        app(XDebug::class)->turnOff();
46
    }
47
}
48