Code Duplication    Length = 20-25 lines in 2 locations

src/Adlogix/Zf2Rollout/Service/Factory/DoctrineORMStorageFactory.php 1 location

@@ 20-44 (lines=25) @@
17
use Zend\ServiceManager\FactoryInterface;
18
use Zend\ServiceManager\ServiceLocatorInterface;
19
20
class DoctrineORMStorageFactory implements FactoryInterface
21
{
22
23
    /**
24
     * Create service
25
     *
26
     * @param ServiceLocatorInterface $serviceLocator
27
     *
28
     * @return mixed
29
     */
30
    public function createService(ServiceLocatorInterface $serviceLocator)
31
    {
32
        /** @var EntityManager $em */
33
        $em = $serviceLocator->get('doctrine.entitymanager.orm_default');
34
35
        /** @var array $rolloutConfig */
36
        $rolloutConfig = $serviceLocator->get('zf2_rollout_config');
37
38
        if (!isset($rolloutConfig['doctrine_storage']['class_name'])) {
39
            throw new \RuntimeException('No "[ doctrine_storage => class_name => "some_class"]" defined in the rollout configuration!"');
40
        }
41
42
        return new DoctrineORMStorage($em, $rolloutConfig['doctrine_storage']['class_name']);
43
    }
44
}

src/Adlogix/Zf2Rollout/Service/Factory/RolloutZendDbAdapterStorageFactory.php 1 location

@@ 20-39 (lines=20) @@
17
use Zend\ServiceManager\FactoryInterface;
18
use Zend\ServiceManager\ServiceLocatorInterface;
19
20
class RolloutZendDbAdapterStorageFactory implements FactoryInterface
21
{
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function createService(ServiceLocatorInterface $serviceLocator)
27
    {
28
        $rolloutConfig = $serviceLocator->get('zf2_rollout_config');
29
30
        if (!isset($rolloutConfig['zend_db_storage']['table_name'])) {
31
            throw new \RuntimeException('Missing table_name config when using zend db storage!');
32
        }
33
34
        /** @var Adapter $adapter */
35
        $adapter = $serviceLocator->get('Zend\Db\Adapter\Adapter');
36
37
        return new ZendDbAdapterStorage($adapter, $rolloutConfig['zend_db_storage']['table_name']);
38
    }
39
}