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

ContainerAwareEventBusFactory::make()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

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