ImmutableEventDispatcherFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
eloc 7
c 2
b 0
f 0
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 1
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