Completed
Push — refactor-entity-validators ( 9b4b77...c6627d )
by Stefano
13:07 queued 10:18
created

DataMapperManagerFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 66.67%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 4
c 3
b 1
f 0
lcom 0
cbo 3
dl 0
loc 27
ccs 6
cts 9
cp 0.6667
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 17 4
1
<?php
2
/**
3
 * @author Stefano Torresi (http://stefanotorresi.it)
4
 * @license See the file LICENSE.txt for copying permission.
5
 * ************************************************
6
 */
7
8
namespace Thorr\Persistence\DataMapper\Manager;
9
10
use Zend\ServiceManager\FactoryInterface;
11
use Zend\ServiceManager\ServiceLocatorInterface;
12
13
class DataMapperManagerFactory implements FactoryInterface
14
{
15
    /**
16
     * Create service
17
     *
18
     * @param ServiceLocatorInterface $serviceLocator
19
     *
20
     * @return DataMapperManager
21
     */
22 6
    public function createService(ServiceLocatorInterface $serviceLocator)
23
    {
24
        $config = $serviceLocator->get('Config');
25
26 6
        $dmmConfig = isset($config['thorr_persistence_dmm'])
27
            ? new DataMapperManagerConfig($config['thorr_persistence_dmm'])
28 6
            : null;
29
30
        $dataMapperManager = new DataMapperManager($dmmConfig);
31
        $dataMapperManager->setServiceLocator($serviceLocator);
32
33 5
        if (isset($config['di']) && $serviceLocator->has('Di')) {
34
            $dataMapperManager->addAbstractFactory($serviceLocator->get('DiAbstractServiceFactory'));
0 ignored issues
show
Documentation introduced by
$serviceLocator->get('DiAbstractServiceFactory') is of type object|array, but the function expects a object<Zend\ServiceManag...actoryInterface>|string.

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...
35
        }
36
37 6
        return $dataMapperManager;
38 6
    }
39
}
40