Test Failed
Pull Request — master (#17)
by Jacek
03:39 queued 02:08
created

EventManager::runWorker()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 3

Importance

Changes 5
Bugs 1 Features 1
Metric Value
c 5
b 1
f 1
dl 0
loc 21
ccs 13
cts 13
cp 1
rs 9.3142
cc 3
eloc 12
nc 3
nop 2
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PHPExtra\EventManager;
6
7
final class EventManager implements EventEmitter
8
{
9
    /**
10
     * @var array
11
     */
12
    private $listeners = [];
13
14
    /**
15
     * @var Notifier
16
     */
17
    private $notifier;
18
19
    public function __construct()
20
    {
21
        $this->notifier = new Notifier();
22
    }
23
24
    public function emit(Event $event): void
25
    {
26
        foreach ($this->listeners as $listener) {
27
            $this->notifier->notify($listener, $event);
28
        }
29
    }
30
31
    public function add(Listener $listener): void
32
    {
33
        $this->listeners[] = $listener;
34
    }
35
}
36