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

EventSubscriber   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 72.72%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 15
c 1
b 0
f 0
dl 0
loc 49
ccs 16
cts 22
cp 0.7272
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A siteRemoved() 0 7 2
A subscribe() 0 5 1
A siteSecured() 0 7 2
A siteUnsecured() 0 7 2
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