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

EventDispatcher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A dispatch() 0 10 2
A __construct() 0 3 1
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