Code Duplication    Length = 30-31 lines in 2 locations

src/EntityManager/OrmEntityLocatorFactory.php 1 location

@@ 21-50 (lines=30) @@
18
 *
19
 * @package Nnx\Doctrine\EntityManager
20
 */
21
class OrmEntityLocatorFactory implements FactoryInterface
22
{
23
    /**
24
     * @inheritdoc
25
     *
26
     * @param ServiceLocatorInterface $serviceLocator
27
     *
28
     * @return OrmEntityLocator
29
     */
30
    public function createService(ServiceLocatorInterface $serviceLocator)
31
    {
32
        $appServiceLocator = $serviceLocator;
33
        if ($appServiceLocator instanceof AbstractPluginManager) {
34
            $appServiceLocator->getServiceLocator();
35
        }
36
37
        /** @var ObjectManagerAutoDetectorInterface $objectManagerAutoDetector */
38
        $objectManagerAutoDetector = $appServiceLocator->get(ObjectManagerAutoDetectorInterface::class);
39
40
        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsManager */
41
        $moduleOptionsManager = $appServiceLocator->get(ModuleOptionsPluginManagerInterface::class);
42
        /** @var ModuleOptionsInterface $moduleOptions */
43
        $moduleOptions = $moduleOptionsManager->get(ModuleOptionsInterface::class);
44
45
        /** @var DoctrineOrmModuleConfigInterface $doctrineOrmModuleConfig */
46
        $doctrineOrmModuleConfig = $appServiceLocator->get(DoctrineOrmModuleConfigInterface::class);
47
48
        return new OrmEntityLocator($objectManagerAutoDetector, $moduleOptions, $doctrineOrmModuleConfig);
49
    }
50
}
51

src/Utils/EntityMapCacheFactory.php 1 location

@@ 20-50 (lines=31) @@
17
 *
18
 * @package Nnx\Doctrine\Utils
19
 */
20
class EntityMapCacheFactory implements FactoryInterface
21
{
22
    /**
23
     * @param ServiceLocatorInterface $serviceLocator
24
     *
25
     * @return EntityMapBuilder
26
     *
27
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
28
     */
29
    public function createService(ServiceLocatorInterface $serviceLocator)
30
    {
31
        /** @var EntityMapBuilderInterface $entityMapBuilder */
32
        $entityMapBuilder = $serviceLocator->get(EntityMapBuilderInterface::class);
33
34
        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsManager */
35
        $moduleOptionsManager = $serviceLocator->get(ModuleOptionsPluginManagerInterface::class);
36
        /** @var ModuleOptionsInterface $moduleOptions */
37
        $moduleOptions = $moduleOptionsManager->get(ModuleOptionsInterface::class);
38
        $cacheServiceName = $moduleOptions->getEntityMapDoctrineCache();
39
40
        if (null === $cacheServiceName) {
41
            $cache = new VoidCache();
42
        } else {
43
            /** @var Cache $cache */
44
            $cache = $serviceLocator->get($cacheServiceName);
45
        }
46
47
48
        return new EntityMapCache($entityMapBuilder, $cache, $moduleOptions);
49
    }
50
}
51