ContainerModelLayerPooler::createClient()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 8
loc 8
rs 10
cc 2
nc 2
nop 1
1
<?php
2
/*
3
 * This file is part of the PommProject/PommBundle package.
4
 *
5
 * (c) 2014 - 2016 Grégoire HUBERT <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PommProject\PommBundle\Model;
11
12
use PommProject\Foundation\Client\ClientPooler;
13
use PommProject\ModelManager\ModelLayer\ModelLayerPooler;
14
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
15
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
16
17
/**
18
 * ModelLayerPooler
19
 *
20
 * Pooler for ModelLayer session client.
21
 *
22
 * @package   ModelManager
23
 * @copyright 2014 - 2016 Grégoire HUBERT
24
 * @author    Miha Vrhovnik
25
 * @license   X11 {@link http://opensource.org/licenses/mit-license.php}
26
 * @see       ClientPooler
27
 */
28 View Code Duplication
class ContainerModelLayerPooler extends ModelLayerPooler implements ContainerAwareInterface, ServiceMapInterface
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...
29
{
30
    use ContainerAwareTrait;
31
32
    private $serviceMap = [];
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function addModelToServiceMapping($class, $serviceId)
38
    {
39
        $this->serviceMap[$class] = $serviceId;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    protected function createClient($class)
46
    {
47
        if (array_key_exists($class, $this->serviceMap)) {
48
            return $this->container->get($this->serviceMap[$class]);
49
        }
50
51
        return parent::createClient($class);
52
    }
53
}
54