Completed
Push — 2.x ( a081e5 )
by Daniel
15:13
created

UserFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
3
namespace ZfcUser\Factory\Service;
4
5
use Interop\Container\ContainerInterface;
6
use Interop\Container\Exception\ContainerException;
7
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
8
use Zend\ServiceManager\Exception\ServiceNotFoundException;
9
use Zend\ServiceManager\Factory\FactoryInterface;
10
use Zend\ServiceManager\ServiceLocatorInterface;
11
use ZfcUser\Service\User;
12
13
class UserFactory implements FactoryInterface
14
{
15
    public function __invoke(ContainerInterface $serviceLocator, $requestedName, array $options = null)
16
    {
17
        $service = new User();
18
        $service->setServiceManager($serviceLocator);
0 ignored issues
show
Compatibility introduced by
$serviceLocator of type object<Interop\Container\ContainerInterface> is not a sub-type of object<Zend\ServiceManager\ServiceManager>. It seems like you assume a concrete implementation 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...
19
        return $service;
20
    }
21
22
    /**
23
     * Create service
24
     *
25
     * @param ServiceLocatorInterface $serviceLocator
26
     * @return mixed
27
     */
28
    public function createService(ServiceLocatorInterface $serviceLocator)
29
    {
30
        return $this->__invoke($serviceLocator, null);
31
    }
32
}
33