Passed
Push — master ( 21c01c...bba7c4 )
by Iman
08:34
created

BasicEventManager::wrapForIgnorance()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 2
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 BasicEventManager
9
{
10
    private $events;
11
12
    /**
13
     * BasicEventManager constructor.
14
     *
15
     * @param $events
16
     *
17
     * @return BasicEventManager
18 8
     */
19
    public function init(array $events): self
20 8
    {
21
        $this->events = $events;
22 8
23
        return $this;
24
    }
25
26
    /**
27
     * @param $listener
28 8
     */
29
    public function startGuarding(callable $listener)
30 8
    {
31 8
        Event::listen($this->events, app(HeyManSwitcher::class)->wrapForIgnorance($listener, 'event'));
32
    }
33
}
34