Completed
Push — master ( 7d4f19...99404e )
by Andrii
01:34
created

ContextContainer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 25
ccs 8
cts 8
cp 1
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 1
    public function __construct(CompositeContextContainer $parent, string $context)
22
    {
23 1
        $this->container = $parent;
24 1
        $this->context = $context;
25 1
    }
26
27 1
    public function get($id)
28
    {
29 1
        return $this->container->getFromContext($id, $this->context);
30
    }
31
32 1
    public function has($id)
33
    {
34 1
        return $this->container->hasInContext($id, $this->context);
35
    }
36
}
37