DoctrineOrmModuleConfigFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 13 2
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/doctrine
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\Doctrine\Utils;
7
8
use Nnx\Doctrine\Options\ModuleOptionsInterface;
9
use Nnx\ModuleOptions\ModuleOptionsPluginManagerInterface;
10
use Zend\ServiceManager\FactoryInterface;
11
use Zend\ServiceManager\ServiceLocatorInterface;
12
13
/**
14
 * Class DoctrineOrmModuleConfigFactory
15
 *
16
 * @package Nnx\Doctrine\Utils
17
 */
18
class DoctrineOrmModuleConfigFactory implements FactoryInterface
19
{
20
    /**
21
     * @inheritdoc
22
     *
23
     * @param ServiceLocatorInterface $serviceLocator
24
     *
25
     * @return DoctrineOrmModuleConfig
26
     *
27
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
28
     */
29
    public function createService(ServiceLocatorInterface $serviceLocator)
30
    {
31
        /** @var array  $appConfig */
32
        $appConfig = $serviceLocator->get('config');
33
        $doctrineConfig = array_key_exists('doctrine', $appConfig) ? $appConfig['doctrine'] : [];
34
35
        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsManager */
36
        $moduleOptionsManager = $serviceLocator->get(ModuleOptionsPluginManagerInterface::class);
37
        /** @var ModuleOptionsInterface $moduleOptions */
38
        $moduleOptions = $moduleOptionsManager->get(ModuleOptionsInterface::class);
39
40
        return new DoctrineOrmModuleConfig($doctrineConfig, $moduleOptions);
41
    }
42
}
43