Completed
Push — sam-rework ( 1696e6 )
by Andrii
38:13 queued 23:11
created

ContextContainer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 27
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A get() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
4
namespace yii\di;
5
6
use Psr\Container\ContainerInterface;
7
8
/**
9
 * This class a container that uses a specific context in a CompositeContextContainer
10
 * The intended use is to allow for custom configurations of (nested) modules.
11
 */
12
class ContextContainer implements ContainerInterface
13
{
14
    /**
15
     * @var CompositeContextContainer
16
     */
17
    private $container;
18
19
    /**
20
     * @var string The context that this container uses
21
     */
22
    private $context;
23
    public function __construct(CompositeContextContainer $parent, string $context)
24
    {
25
        $this->container = $parent;
26
        $this->context = $context;
27
    }
28
29
    /** @inheritdoc */
30
    public function get($id)
31
    {
32
        return $this->container->getFromContext($id, $this->context);
33
    }
34
35
    /** @inheritdoc */
36
    public function has($id)
37
    {
38
        return $this->container->hasInContext($id, $this->context);
39
    }
40
}
41