ConfigurationFactory::createService()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Fabiang\DoctrineDynamic\Service;
4
5
use Fabiang\DoctrineDynamic\Configuration;
6
use Fabiang\DoctrineDynamic\ConfigurationFactory as BaseConfigurationFactory;
7
use Interop\Container\ContainerInterface;
8
use Zend\ServiceManager\FactoryInterface;
9
use Zend\ServiceManager\ServiceLocatorInterface;
10
11
class ConfigurationFactory extends BaseConfigurationFactory implements
12
    FactoryInterface
13
{
14
    /**
15
     * @param ContainerInterface $container
16
     * @param string $requestedName
17
     * @param array $options
18
     * @return Configuration
19
     */
20 1
    public function __invoke(
21
        ContainerInterface $container,
22
        $requestedName,
23
        array $options = null
24
    ) {
25 1
        $globalConfiguration = $container->get('configuration');
26
27 1
        $configuration = [];
28 1
        if (isset($globalConfiguration['doctrine_dynamic'])
29 1
            && is_array($globalConfiguration['doctrine_dynamic'])) {
30 1
            $configuration = $globalConfiguration['doctrine_dynamic'];
31
        }
32
33 1
        return $this->factory($configuration);
34
    }
35
36
    /**
37
     * @param ServiceLocatorInterface $serviceLocator
38
     * @return Configuration
39
     */
40 1
    public function createService(ServiceLocatorInterface $serviceLocator)
41
    {
42 1
        return $this($serviceLocator, Configuration::class);
43
    }
44
}
45