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

CommandBusFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 8
Bugs 0 Features 0
Metric Value
wmc 2
c 8
b 0
f 0
lcom 0
cbo 2
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 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