ImmutableEventDispatcherFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 14
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\LaminasEvent\Factory;
6
7
use Arp\EventDispatcher\ImmutableEventDispatcher;
8
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
9
use Laminas\ServiceManager\ServiceLocatorInterface;
10
use Psr\Container\ContainerExceptionInterface;
11
use Psr\Container\ContainerInterface;
12
use Psr\EventDispatcher\ListenerProviderInterface;
13
14
final class ImmutableEventDispatcherFactory extends AbstractEventDispatcherFactory
15
{
16
    /**
17
     * @param ContainerInterface&ServiceLocatorInterface $container
18
     *
19
     * @throws ServiceNotCreatedException
20
     * @throws ContainerExceptionInterface
21
     */
22
    public function __invoke(
23
        ContainerInterface $container,
24
        string $requestedName,
25
        array $options = null
26
    ): ImmutableEventDispatcher {
27
        $options = $options ?? $this->getServiceOptions($container, $requestedName, 'event_dispatchers');
28
29
        $listenerProvider = $this->getListenerProvider(
30
            $container,
31
            $options['listener_provider'] ?? ListenerProviderInterface::class,
32
            $requestedName
33
        );
34
35
        return new ImmutableEventDispatcher($listenerProvider);
36
    }
37
}
38