EventDispatcher   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 4
c 1
b 0
f 0
dl 0
loc 28
ccs 2
cts 2
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getListenerProvider() 0 3 1
A addListenerForEvent() 0 3 1
A addListenersForEvent() 0 3 1
A __construct() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\EventDispatcher;
6
7
use Arp\EventDispatcher\Listener\AddableListenerProviderInterface;
8
use Arp\EventDispatcher\Listener\AddListenerAwareInterface;
9
use Arp\EventDispatcher\Listener\Exception\EventListenerException;
10
use Psr\EventDispatcher\ListenerProviderInterface;
11
12
final class EventDispatcher extends AbstractEventDispatcher implements AddListenerAwareInterface
13
{
14
    public function __construct(private readonly AddableListenerProviderInterface $listenerProvider)
15
    {
16
    }
17
18
    /**
19
     * @throws EventListenerException
20
     */
21
    public function addListenerForEvent(object|string $event, callable $listener, int $priority = 1): void
22
    {
23
        $this->listenerProvider->addListenerForEvent($event, $listener, $priority);
24
    }
25
26 12
    /**
27
     * @throws EventListenerException
28 12
     */
29
    public function addListenersForEvent(string|object $event, iterable $listeners, int $priority = 1): void
30
    {
31
        $this->listenerProvider->addListenersForEvent($event, $listeners, $priority);
32
    }
33
34
    /**
35
     * @return ListenerProviderInterface
36
     */
37
    protected function getListenerProvider(): ListenerProviderInterface
38
    {
39
        return $this->listenerProvider;
40 1
    }
41
}
42