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

ContextContainer::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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 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