Completed
Push — master ( 3aa853...4b5a00 )
by Toni
02:11
created

DoctrineORMStorageFactory::createService()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 6

Duplication

Lines 14
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 14
loc 14
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
/*
3
 * This file is part of the Adlogix package.
4
 *
5
 * (c) Allan Segebarth <[email protected]>
6
 * (c) Jean-Jacques Courtens <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Adlogix\Zf2Rollout\Service\Factory;
13
14
15
use Adlogix\Zf2Rollout\Storage\Doctrine\DoctrineORMStorage;
16
use Doctrine\ORM\EntityManager;
17
use Zend\ServiceManager\FactoryInterface;
18
use Zend\ServiceManager\ServiceLocatorInterface;
19
20 View Code Duplication
class DoctrineORMStorageFactory implements FactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
}