Completed
Push — master ( e15c58...b150a8 )
by Changwan
07:08
created

InstanceContainee::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Wandu\DI\Containee;
3
4
use Wandu\DI\ContainerInterface;
5
6
class InstanceContainee extends ContaineeAbstract
7
{
8
    /** @var mixed */
9
    protected $source;
10
    
11
    /**
12
     * @param mixed $source
13
     */
14 63
    public function __construct($source)
15
    {
16 63
        $this->source = $source;
17 63
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 25
    public function get(ContainerInterface $container)
23
    {
24 25
        $this->frozen = true;
25 25
        if (!isset($this->caching)) {
26 25
            $this->caching = $this->source;
27 25
        }
28 25
        if ($this->factoryEnabled) {
29 1
            return clone $this->caching;
30
        }
31 25
        return $this->caching;
32
    }
33
}
34