Registry   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 57
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A has() 0 4 1
A get() 0 4 1
A add() 0 4 1
1
<?php
2
3
namespace Pim\Bundle\CustomEntityBundle\Configuration;
4
5
use Symfony\Component\DependencyInjection\ContainerInterface;
6
7
/**
8
 * Registry of configurations
9
 *
10
 * @author    Antoine Guigan <[email protected]>
11
 * @copyright 2013 Akeneo SAS (http://www.akeneo.com)
12
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
13
 */
14
class Registry
15
{
16
    /**
17
     * @var ContainerInterface
18
     */
19
    protected $container;
20
21
    /**
22
     * @var array
23
     */
24
    protected $configurations = array();
25
26
    /**
27
     * Constructor
28
     *
29
     * @param ContainerInterface $container
30
     */
31
    public function __construct(ContainerInterface $container)
32
    {
33
        $this->container = $container;
34
    }
35
36
    /**
37
     * Returns true if a configuration with the corresponding name exists
38
     *
39
     * @param string $name
40
     *
41
     * @return boolean
42
     */
43
    public function has($name)
44
    {
45
        return isset($this->configurations[$name]);
46
    }
47
48
    /**
49
     * Get a configuration
50
     *
51
     * @param string $name
52
     *
53
     * @return ConfigurationInterface
54
     */
55
    public function get($name)
56
    {
57
        return $this->container->get($this->configurations[$name]);
58
    }
59
60
    /**
61
     * Add a configuration
62
     *
63
     * @param string $name
64
     * @param string $serviceId
65
     */
66
    public function add($name, $serviceId)
67
    {
68
        $this->configurations[$name] = $serviceId;
69
    }
70
}
71