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

EventSubscriber::siteUnsecured()   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
eloc 3
c 1
b 0
f 0
dl 0
loc 7
ccs 3
cts 4
cp 0.75
rs 10
cc 2
nc 2
nop 1
crap 2.0625
1
<?php
2
3
namespace App\Support\Valet;
4
5
use App\Events\SiteRemoved;
6
use App\Events\SiteSecured;
7
use App\Events\SiteUnsecured;
8
9
class EventSubscriber
10
{
11
    /** @var Valet */
12
    protected $valet;
13
14 206
    public function __construct(Valet $valet)
15
    {
16 206
        $this->valet = $valet;
17 206
    }
18
19 2
    public function siteSecured(SiteSecured $event)
20
    {
21 2
        if (setting('use_valet', 'off') === 'off') {
22 2
            return;
23
        }
24
25
        $this->valet->addSite($event->site);
26
    }
27
28 2
    public function siteUnsecured(SiteUnsecured $event)
29
    {
30 2
        if (setting('use_valet', 'off') === 'off') {
31 2
            return;
32
        }
33
34
        $this->valet->addSite($event->site);
35
    }
36
37 1
    public function siteRemoved(SiteRemoved $event)
38
    {
39 1
        if (setting('use_valet', 'off') === 'off') {
40 1
            return;
41
        }
42
43
        $this->valet->removeSite($event->site);
44
    }
45
46
    /**
47
     * Register the listeners for the subscriber.
48
     *
49
     * @param \Illuminate\Events\Dispatcher $events
50
     *
51
     * @return void
52
     */
53 206
    public function subscribe($events)
54
    {
55 206
        $events->listen(SiteSecured::class, static::class.'@siteSecured');
56 206
        $events->listen(SiteUnsecured::class, static::class.'@siteUnsecured');
57 206
        $events->listen(SiteRemoved::class, static::class.'@siteRemoved');
58 206
    }
59
}
60