EventDispatcher::addListenerForEvent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 3
crap 2
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