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

EmitterFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 13
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 7
nc 1
nop 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