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

EventManager::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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