Completed
Push — 1.x ( 647e2f...f3d5fa )
by Daniel
11s
created

UserFactory::createService()   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 1
1
<?php
2
3
namespace ZfcUser\Factory\Service;
4
5
use Zend\ServiceManager\FactoryInterface;
6
use Zend\ServiceManager\ServiceLocatorInterface;
7
use ZfcUser\Service\User;
8
9
class UserFactory implements FactoryInterface
10
{
11
12
    /**
13
     * Create service
14
     *
15
     * @param ServiceLocatorInterface $serviceLocator
16
     * @return mixed
17
     */
18
    public function createService(ServiceLocatorInterface $serviceLocator)
19
    {
20
        $service = new User();
21
        $service->setServiceManager($serviceLocator);
0 ignored issues
show
Compatibility introduced by
$serviceLocator of type object<Zend\ServiceManag...erviceLocatorInterface> is not a sub-type of object<Zend\ServiceManager\ServiceManager>. It seems like you assume a concrete implementation of the interface Zend\ServiceManager\ServiceLocatorInterface 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...
22
        return $service;
23
    }
24
}
25