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

ContextContainer::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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