Completed
Push — master ( 7cf2a7...686a12 )
by Matthias
09:06
created

LegacyControllerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createService() 0 4 1
A __invoke() 0 8 1
1
<?php
2
3
4
namespace MaglLegacyApplication\Factory;
5
6
7
use Interop\Container\ContainerInterface;
8
use Interop\Container\Exception\ContainerException;
9
use MaglLegacyApplication\Application\MaglLegacy;
10
use MaglLegacyApplication\Controller\LegacyController;
11
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
12
use Zend\ServiceManager\Exception\ServiceNotFoundException;
13
use Zend\ServiceManager\FactoryInterface;
14
use Zend\ServiceManager\ServiceLocatorInterface;
15
16
class LegacyControllerFactory implements FactoryInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Zend\ServiceManager\FactoryInterface has been deprecated with message: Use Zend\ServiceManager\Factory\FactoryInterface instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
17
{
18
19
    /**
20
     * Create service
21
     *
22
     * @param ServiceLocatorInterface $serviceLocator
23
     * @return mixed
24
     */
25
    public function createService(ServiceLocatorInterface $serviceLocator)
26
    {
27
        return $this->__invoke($serviceLocator->getServiceLocator(), 'MaglLegacyApplication\Controller\Legacy');
28
    }
29
30
    /**
31
     * Create an object
32
     *
33
     * @param ContainerInterface $container
34
     * @param string $requestedName
35
     * @param null|array $options
36
     * @return object
37
     * @throws ServiceNotFoundException if unable to resolve the service.
38
     * @throws ServiceNotCreatedException if an exception is raised when
39
     *     creating a service.
40
     * @throws ContainerException if any other error occurs
41
     */
42
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
43
    {
44
        $options = $container->get('MaglLegacyApplicationOptions');
45
46
        $legacyApp = MaglLegacy::getInstance();
47
48
        return new LegacyController($options, $legacyApp);
49
    }
50
}
51