Completed
Push — master ( 99ca87...95904e )
by Andrey
23:44
created

XmlDoctrineObjectConstructorSubscriberFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 11 1
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/jms-serializer-module
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\JmsSerializerModule\EventDispatcher;
7
8
use Interop\Container\ContainerInterface;
9
use Nnx\JmsSerializerModule\DataContainerBuilder\XmlBuilderInterface;
10
use Zend\ServiceManager\FactoryInterface;
11
use Zend\ServiceManager\ServiceLocatorInterface;
12
use Doctrine\Common\Persistence\ManagerRegistry;
13
14
/**
15
 * Class XmlDoctrineObjectConstructorSubscriberFactory
16
 *
17
 * @package Nnx\JmsSerializerModule\EventDispatcher
18
 */
19
class XmlDoctrineObjectConstructorSubscriberFactory implements FactoryInterface
20
{
21
    /**
22
     * @param ServiceLocatorInterface $serviceLocator
23
     *
24
     * @return XmlDoctrineObjectConstructorSubscriber
25
     * @throws \Interop\Container\Exception\NotFoundException
26
     * @throws \Interop\Container\Exception\ContainerException
27
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
28
     */
29
    public function createService(ServiceLocatorInterface $serviceLocator)
30
    {
31
        /** @var ContainerInterface $serviceLocator */
32
        /** @var ManagerRegistry $managerRegistry */
33
        $managerRegistry = $serviceLocator->get(ManagerRegistry::class);
34
35
        /** @var XmlBuilderInterface $dataContainerFromXmlBuilder */
36
        $dataContainerFromXmlBuilder = $serviceLocator->get(XmlBuilderInterface::class);
37
38
        return new XmlDoctrineObjectConstructorSubscriber($managerRegistry, $dataContainerFromXmlBuilder, $serviceLocator);
0 ignored issues
show
Documentation introduced by
$serviceLocator is of type object<Zend\ServiceManag...erviceLocatorInterface>, but the function expects a object<Interop\Container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39
    }
40
}
41