IndexControllerFactory::createService()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 24
rs 9.536
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author stev leibelt <[email protected]>
4
 * @since 2015-06-04
5
 */
6
7
namespace NetBazzlineZfLocatorGenerator\Controller\Console;
8
9
use Net\Bazzline\Component\ProcessPipe\PipeInterface;
10
use Zend\ServiceManager\Exception\InvalidArgumentException;
11
use Zend\ServiceManager\ServiceLocatorInterface;
12
use ZfConsoleHelper\Controller\Console\AbstractConsoleControllerFactory;
13
14
class IndexControllerFactory extends AbstractConsoleControllerFactory
15
{
16
    /**
17
     * Create service
18
     *
19
     * @param ServiceLocatorInterface $serviceLocator
20
     *
21
     * @return mixed|IndexController
22
     */
23
    public function createService(ServiceLocatorInterface $serviceLocator)
24
    {
25
        $controller     = new IndexController();
26
        $serviceLocator = $this->transformIntoServiceManager($serviceLocator);
27
28
        /** @var array|\Zend\Config\Config $configuration */
29
        $configuration  = $serviceLocator->get('Config');
30
        $key            = 'net_bazzline_zf_locator_generator';
31
32
        if (!isset($configuration[$key])) {
33
            throw new InvalidArgumentException (
34
                'expected configuration key "' . $key . '" not found'
35
            );
36
        }
37
38
        $configuration  = $configuration[$key];
39
        /** @var PipeInterface $pipe */
40
        $pipe           = $serviceLocator->get('NetBazzlineLocatorGeneratorProcessPipe');
41
42
        $controller->setConfiguration($configuration);
43
        $controller->setProcessPipe($pipe);
44
45
        return $controller;
46
    }
47
}