AspectKernelFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 4 1
A createService() 0 7 1
1
<?php
2
/*
3
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2016, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Go\Zend\Framework\Factory;
12
13
use Go\Zend\Framework\Kernel\AspectKernel;
14
use Go\Zend\Framework\Module;
15
use Interop\Container\ContainerInterface;
16
use Zend\ServiceManager\FactoryInterface;
17
use Zend\ServiceManager\ServiceLocatorInterface;
18
19
class AspectKernelFactory 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...
20
{
21
22
    /**
23
     * Create service
24
     *
25
     * This method gains ZF3 compatibility
26
     *
27
     * @param ContainerInterface $container
28
     * @param string             $requestedName
29
     * @param array              $options
30
     *
31
     * @return mixed
32
     */
33
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
34
    {
35
        return $this->createService($container);
0 ignored issues
show
Compatibility introduced by
$container of type object<Interop\Container\ContainerInterface> is not a sub-type of object<Zend\ServiceManag...erviceLocatorInterface>. It seems like you assume a child interface of the interface Interop\Container\ContainerInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
36
    }
37
38
    /**
39
     * Create service
40
     *
41
     * @param ServiceLocatorInterface $serviceLocator
42
     *
43
     * @return mixed
44
     */
45
    public function createService(ServiceLocatorInterface $serviceLocator)
46
    {
47
        $aspectKernel = AspectKernel::getInstance();
48
        $aspectKernel->init($serviceLocator->get('config')[Module::CONFIG_KEY]);
49
50
        return $aspectKernel;
51
    }
52
}
53