Completed
Push — master ( d10f54...00ced4 )
by
unknown
05:32
created

AbstractPropertyDefinition   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 34
rs 10
c 0
b 0
f 0
ccs 9
cts 9
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A setDependency() 0 6 1
A getDependency() 0 4 1
1
<?php declare(strict_types = 1);
2
/**
3
 * Created by PhpStorm.
4
 * User: root
5
 * Date: 02.08.16
6
 * Time: 0:46.
7
 */
8
namespace samsonframework\container\definition;
9
10
use samsonframework\container\definition\reference\ReferenceInterface;
11
use samsonframework\container\definition\reference\UndefinedReference;
12
13
/**
14
 * Class AbstractPropertyDefinition
15
 *
16
 * @author Ruslan Molodyko <[email protected]>
17
 */
18
abstract class AbstractPropertyDefinition extends AbstractDefinition
19
{
20
    /** @var ReferenceInterface */
21
    protected $dependency;
22
23
    /** {@inheritdoc} */
24 23
    public function __construct(AbstractDefinition $parentDefinition = null)
25
    {
26 23
        parent::__construct($parentDefinition);
27
28
        // For each new dependency classes set undefined reference as dependency has not resolved yet
29
        // Undefined reference equivalent to null reference
30 23
        $this->dependency = new UndefinedReference();
31 23
    }
32
33
    /**
34
     * @param ReferenceInterface $dependency
35
     * @return AbstractPropertyDefinition
36
     */
37 4
    public function setDependency(ReferenceInterface $dependency): AbstractPropertyDefinition
38
    {
39 4
        $this->dependency = $dependency;
40
41 4
        return $this;
42
    }
43
44
    /**
45
     * @return ReferenceInterface
46
     */
47 16
    public function getDependency(): ReferenceInterface
48
    {
49 16
        return $this->dependency;
50
    }
51
}
52