Passed
Push — master ( e437b2...21ca17 )
by Iman
08:24
created

EventManager   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 5 1
A startGuarding() 0 3 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\WatchingStrategies;
4
5
use Illuminate\Support\Facades\Event;
6
use Imanghafoori\HeyMan\HeyManSwitcher;
7
8
class EventManager
9
{
10
    private $events;
11
12
    /**
13
     * BasicEventManager constructor.
14
     *
15
     * @param $events
16
     *
17
     * @return EventManager
18
     */
19
    public function init(array $events): self
20
    {
21
        $this->events = $events;
22
23
        return $this;
24
    }
25
26
    /**
27
     * @param $listener
28
     */
29
    public function startGuarding(callable $listener)
30
    {
31
        Event::listen($this->events, app(HeyManSwitcher::class)->wrapForIgnorance($listener, 'event'));
32
    }
33
}
34