Completed
Push — master ( a62be0...cf7bb9 )
by Baptiste
02:50
created

ContainerAwareEventBusFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 21
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 18 3
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\EventBusBundle\Factory;
5
6
use Innmind\EventBusBundle\ContainerAwareEventBus;
7
use Innmind\Immutable\{
8
    Map,
9
    SetInterface,
10
    Set
11
};
12
use Symfony\Component\DependencyInjection\ContainerInterface;
13
14
final class ContainerAwareEventBusFactory
15
{
16 3
    public static function make(
17
        ContainerInterface $container,
18
        array $services
19
    ): ContainerAwareEventBus {
20 3
        $map = new Map('string', SetInterface::class);
21
22 3
        foreach ($services as $class => $listeners) {
23 3
            $set = new Set('string');
24
25 3
            foreach ($listeners as $listener) {
26 3
                $set = $set->add($listener);
27
            }
28
29 3
            $map = $map->put($class, $set);
30
        }
31
32 3
        return new ContainerAwareEventBus($container, $map);
33
    }
34
}
35