Passed
Push — main ( fdd579...0d07d8 )
by Fabian
04:34 queued 02:09
created

ConfigurationFactory::createService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Fabiang\DoctrineDynamic\Service;
6
7
use Fabiang\DoctrineDynamic\Configuration;
8
use Fabiang\DoctrineDynamic\ConfigurationFactory as BaseConfigurationFactory;
9
use Laminas\ServiceManager\Factory\FactoryInterface;
10
use Psr\Container\ContainerInterface;
11
12
use function is_array;
13
14
class ConfigurationFactory extends BaseConfigurationFactory implements
15
    FactoryInterface
16
{
17
    /**
18
     * @param string $requestedName
19
     */
20 1
    public function __invoke(
21
        ContainerInterface $container,
22
        $requestedName,
23
        ?array $options = null
24
    ): Configuration {
25 1
        $globalConfiguration = $container->get('configuration');
26
27 1
        $configuration = [];
28
        if (
29 1
            isset($globalConfiguration['doctrine_dynamic'])
30 1
            && is_array($globalConfiguration['doctrine_dynamic'])
31
        ) {
32 1
            $configuration = $globalConfiguration['doctrine_dynamic'];
33
        }
34
35 1
        return $this->factory($configuration);
36
    }
37
}
38