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

CommandHandlerMiddlewareFactory::createService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 15
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
crap 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