Passed
Push — master ( 08dd0c...2460e1 )
by Koldo
02:21
created

EmitterFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
dl 0
loc 15
rs 10
c 1
b 0
f 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 13 1
1
<?php
2
3
namespace InFw\TacticianAdapter\Factory;
4
5
use InFw\EventSourcing\Emitter;
6
use Psr\Container\ContainerInterface;
7
8
class EmitterFactory
9
{
10
    public function __invoke(ContainerInterface $container)
11
    {
12
        $events = $container->get('config')['events'];
13
14
        $emitter = Emitter::instance();
15
16
        array_walk($events, function ($listeners, $event) use ($container, $emitter) {
17
            array_map(function ($listener) use ($container, $emitter, $event) {
18
                $emitter->addListener($event, $container->get($listener));
19
            }, $listeners);
20
        });
21
22
        return $emitter;
23
    }
24
}
25