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

EventSubscriber::setXDebug()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 10
1
<?php
2
3
namespace App\Support\XDebug;
4
5
use App\Events\StartedPorter;
6
use App\Events\StartedPorterService;
7
8
class EventSubscriber
9
{
10
    /** @var XDebug */
11
    protected $xdebug;
12
13 206
    public function __construct(XDebug $xdebug)
14
    {
15 206
        $this->xdebug = $xdebug;
16 206
    }
17
18 3
    public function setXDebug()
19
    {
20 3
        if (setting('use_xdebug', 'on') === 'off') {
21
            $this->xdebug->turnOff();
22
        }
23
24 3
        $this->xdebug->turnOn();
25 3
    }
26
27
    /**
28
     * Register the listeners for the subscriber.
29
     *
30
     * @param \Illuminate\Events\Dispatcher $events
31
     *
32
     * @return void
33
     */
34 206
    public function subscribe($events)
35
    {
36 206
        $events->listen(StartedPorter::class, static::class.'@setXDebug');
37 206
        $events->listen(StartedPorterService::class, static::class.'@setXDebug');
38 206
    }
39
}
40