Completed
Push — master ( fadeb4...d2fa33 )
by Alexander
02:05
created

ContextContainer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Yiisoft\Di;
3
4
use Psr\Container\ContainerInterface;
5
6
/**
7
 * This class a container that uses a specific context in a CompositeContextContainer
8
 * The intended use is to allow for custom configurations of (nested) modules.
9
 */
10
class ContextContainer implements ContainerInterface
11
{
12
    /**
13
     * @var CompositeContextContainer
14
     */
15
    private $container;
16
17
    /**
18
     * @var string The context that this container uses
19
     */
20
    private $context;
21
    public function __construct(CompositeContextContainer $parent, string $context)
22
    {
23
        $this->container = $parent;
24
        $this->context = $context;
25
    }
26
27
    public function get($id)
28
    {
29
        return $this->container->getFromContext($id, $this->context);
30
    }
31
32
    public function has($id)
33
    {
34
        return $this->container->hasInContext($id, $this->context);
35
    }
36
}
37