RolloutControllerFactory::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 3
1
<?php
2
/*
3
 * This file is part of the Adlogix package.
4
 *
5
 * (c) Allan Segebarth <[email protected]>
6
 * (c) Jean-Jacques Courtens <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Adlogix\Zf2Rollout\Service\Factory;
13
14
15
use Adlogix\Zf2Rollout\Service\Controller\RolloutController;
16
use Interop\Container\ContainerInterface;
17
use Opensoft\Rollout\Rollout;
18
use Opensoft\Rollout\RolloutUserInterface;
19
use Zend\Mvc\Controller\ControllerManager;
20
use Zend\ServiceManager\FactoryInterface;
21
use Zend\ServiceManager\ServiceLocatorInterface;
22
23
/**
24
 * @author Toni Van de Voorde <[email protected]>
25
 */
26
final class RolloutControllerFactory implements FactoryInterface
27
{
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function createService(ServiceLocatorInterface $serviceLocator)
33
    {
34
        return $this($serviceLocator, null);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
41
    {
42
        if ($container instanceof ControllerManager) {
43
            $container = $container->getServiceLocator();
44
        }
45
46
        /** @var Rollout $rollout */
47
        $rollout = $container->get('zf2_rollout');
48
49
        /** @var RolloutUserInterface $rolloutUser */
50
        $rolloutUser = $container->get('zf2_rollout_user');
51
52
        return new RolloutController($rollout, $rolloutUser);
53
    }
54
}
55