Completed
Push — master ( 0b79b7...fa8b49 )
by Dawid
10s
created

Container::__construct()   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 declare(strict_types=1);
2
3
namespace Igni\Application;
4
5
use Igni\Container\ServiceLocator;
6
use Psr\Container\ContainerInterface;
7
8
final class Container extends ServiceLocator
9
{
10
    private $baseContainer;
11
12 17
    public function __construct(ContainerInterface $container = null)
13
    {
14 17
        $this->baseContainer = $container;
15 17
    }
16
17 17
    public function get($id, string $context = '')
18
    {
19 17
        if ($this->baseContainer && $this->baseContainer->has($id)) {
20
            return $this->baseContainer->get($id);
21
        }
22
23 17
        return parent::get($id, $context);
24
    }
25
26 17
    public function has($id, string $context = ''): bool
27
    {
28 17
        return ($this->baseContainer && $this->baseContainer->has($id)) || parent::has($id, $context);
29
    }
30
}
31