Completed
Pull Request — master (#8)
by
unknown
15:43
created

CommandBusFactory::createService()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 7
Bugs 0 Features 0
Metric Value
c 7
b 0
f 0
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
crap 2
1
<?php
2
namespace TacticianModule\Factory;
3
4
use Interop\Container\ContainerInterface;
5
use League\Tactician\CommandBus;
6
use League\Tactician\Middleware;
7
use Zend\ServiceManager\Factory\FactoryInterface;
8
9
class CommandBusFactory implements FactoryInterface
10
{
11
    /**
12
     * Create service
13
     *
14
     * @param ContainerInterface $container
15
     * @param string $requestedName
16
     * @param array $options
17
     * @return CommandBus
18 4
     */
19
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
20 4
    {
21 4
        $configMiddleware = $container->get('config')['tactician']['middleware'];
22
23 4
        arsort($configMiddleware);
24 1
25
        $list = [];
26
        foreach (array_keys($configMiddleware) as $serviceName) {
27 3
            /** @var Middleware $middleware */
28
            $list[] = $container->get($serviceName);
29 3
        }
30 3
31
        return new CommandBus($list);
32 3
    }
33
}
34