IndexControllerFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 24 2
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
}