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

CommandHandlerMiddlewareFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 15 1
1
<?php
2
namespace TacticianModule\Factory;
3
4
use Interop\Container\ContainerInterface;
5
use League\Tactician\Handler\CommandHandlerMiddleware;
6
use League\Tactician\Handler\CommandNameExtractor\CommandNameExtractor;
7
use League\Tactician\Handler\Locator\HandlerLocator;
8
use League\Tactician\Handler\MethodNameInflector\MethodNameInflector;
9
use Zend\ServiceManager\Factory\FactoryInterface;
10
11
class CommandHandlerMiddlewareFactory implements FactoryInterface
12
{
13
    /**
14
     * Create service
15
     *
16
     * @param ContainerInterface $container
17
     * @param string $requestedName
18
     * @param array $options
19 2
     * @return CommandHandlerMiddleware
20
     */
21 2
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
22
    {
23
        $config = $container->get('config')['tactician'];
24 2
25
        /** @var CommandNameExtractor $extractor */
26
        $extractor = $container->get($config['default-extractor']);
27 2
28
        /** @var HandlerLocator $locator */
29
        $locator = $container->get($config['default-locator']);
30 2
31
        /** @var MethodNameInflector $inflector */
32 2
        $inflector = $container->get($config['default-inflector']);
33
34
        return new CommandHandlerMiddleware($extractor, $locator, $inflector);
35
    }
36
}
37