Passed
Pull Request — master (#105)
by Evgeniy
08:08 queued 04:03
created

Compiled::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cekta\DI\Container;
6
7
use Psr\Container\ContainerInterface;
8
9
class Compiled extends KeyValue
10
{
11
    /**
12
     * @var ContainerInterface
13
     */
14
    private $container;
15
16 6
    public function __construct(array $values, ContainerInterface $container)
17
    {
18 6
        parent::__construct($values);
19 6
        $this->container = $container;
20 6
    }
21
22 6
    public function get($id)
23
    {
24 6
        $result = parent::get($id);
25 6
        if (is_callable($result)) {
26 3
            $result = $result($this->container);
27
        }
28 6
        return $result;
29
    }
30
}
31