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

ContextContainer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 25
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 3 1
A has() 0 3 1
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