ServiceManagerFactory   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
lcom 0
cbo 3
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getServiceManager() 0 16 2
1
<?php
2
3
namespace DoctrineORMModuleTest;
4
5
use Laminas\Mvc\Service\ServiceManagerConfig;
6
use Laminas\ServiceManager\ServiceManager;
7
8
/**
9
 * Utility used to retrieve a freshly bootstrapped application's service manager
10
 *
11
 * @license MIT
12
 * @link    http://www.doctrine-project.org/
13
 * @author  Marco Pivetta <[email protected]>
14
 */
15
class ServiceManagerFactory
16
{
17
    /**
18
     * Builds a new ServiceManager instance
19
     *
20
     * @param  array|null     $configuration
21
     * @return ServiceManager
22
     */
23
    public static function getServiceManager(array $configuration = null)
24
    {
25
        $configuration        = $configuration ?: include __DIR__ . '/../config.php';
26
        $serviceManager       = new ServiceManager();
27
        $serviceManagerConfig = new ServiceManagerConfig(
28
            $configuration['service_manager'] ?? []
29
        );
30
        $serviceManagerConfig->configureServiceManager($serviceManager);
31
        $serviceManager->setService('ApplicationConfig', $configuration);
32
33
        /** @var $moduleManager \Laminas\ModuleManager\ModuleManager */
34
        $moduleManager = $serviceManager->get('ModuleManager');
35
        $moduleManager->loadModules();
36
37
        return $serviceManager;
38
    }
39
}
40