ConfigurationFactory::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 16
ccs 7
cts 7
cp 1
crap 3
rs 10
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