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

InstanceContainee   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 11 3
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