Completed
Push — master ( acc9c4...a30c3e )
by BruceScrutinizer
06:36
created

EventDispatcher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace NamespaceProtector\Event;
4
5
use Psr\EventDispatcher\StoppableEventInterface;
6
use Psr\EventDispatcher\EventDispatcherInterface;
7
use Psr\EventDispatcher\ListenerProviderInterface;
8
9
class EventDispatcher implements EventDispatcherInterface
10
{
11
    /** @var ListenerProviderInterface*/
12
    private $listenerProvider;
13
14
    public function __construct(ListenerProviderInterface $listenerProvider)
15
    {
16
        $this->listenerProvider = $listenerProvider;
17
    }
18
19
    public function dispatch(object $event)
20
    {
21
        foreach ($this->listenerProvider->getListenersForEvent($event) as $listener) {
22
            // if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
23
            //     break;
24
            // }
25
26
            $listener($event);
27
        }
28
        return $event;
29
    }
30
}
31