ResourceLoaderServiceFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 5
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 19 2
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/doctrine-fixture-module
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\DoctrineFixtureModule\ResourceLoader;
7
8
use Nnx\ModuleOptions\ModuleOptionsPluginManagerInterface;
9
use Zend\ServiceManager\AbstractPluginManager;
10
use Zend\ServiceManager\FactoryInterface;
11
use Zend\ServiceManager\ServiceLocatorInterface;
12
use Nnx\DoctrineFixtureModule\Options\ModuleOptions;
13
14
/**
15
 * Class ResourceLoaderServiceFactory
16
 *
17
 * @package Nnx\DoctrineFixtureModule\ResourceLoader
18
 */
19
class ResourceLoaderServiceFactory implements FactoryInterface
20
{
21
    /**
22
     * @inheritDoc
23
     *
24
     * @return ResourceLoaderService
25
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
26
     */
27
    public function createService(ServiceLocatorInterface $serviceLocator)
28
    {
29
        $appServiceLocator = $serviceLocator instanceof AbstractPluginManager ? $serviceLocator->getServiceLocator() : $serviceLocator;
30
31
        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */
32
        $moduleOptionsPluginManager = $appServiceLocator->get(ModuleOptionsPluginManagerInterface::class);
33
34
        /** @var ModuleOptions $moduleOptions */
35
        $moduleOptions = $moduleOptionsPluginManager->get(ModuleOptions::class);
36
37
        /** @var ResourceLoaderManagerInterface $resourceLoaderManager */
38
        $resourceLoaderManager = $appServiceLocator->get(ResourceLoaderManagerInterface::class);
39
40
        $resourceLoaderService = new ResourceLoaderService($resourceLoaderManager);
41
42
        $resourceLoaderService->setClassFixtureToResourceLoader($moduleOptions->getResourceLoader());
43
44
        return $resourceLoaderService;
45
    }
46
}
47