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

AbstractDefinition   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A end() 0 4 1
A getParentDefinition() 0 8 2
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\exception\ParentDefinitionNotFoundException;
11
12
/**
13
 * Class AbstractDefinition
14
 *
15
 * @package samsonframework\container\definition
16
 */
17
abstract class AbstractDefinition
18
{
19
    /** @var AbstractDefinition Parent definition */
20
    protected $parentDefinition;
21
22
    /**
23
     * AbstractDefinition constructor.
24
     *
25
     * @param AbstractDefinition $parentDefinition
26
     */
27 46
    public function __construct(AbstractDefinition $parentDefinition = null)
28
    {
29 46
        $this->parentDefinition = $parentDefinition;
30 46
    }
31
32
    /**
33
     * End definition and get control to parent
34
     *
35
     * @return AbstractDefinition
36
     * @throws ParentDefinitionNotFoundException
37
     */
38 24
    public function end(): AbstractDefinition
39
    {
40 24
        return $this->getParentDefinition();
41
    }
42
43
    /**
44
     * Get parent definition
45
     *
46
     * @return AbstractDefinition
47
     * @throws ParentDefinitionNotFoundException
48
     */
49 26
    public function getParentDefinition(): AbstractDefinition
50
    {
51 26
        if ($this->parentDefinition === null) {
52 2
            throw new ParentDefinitionNotFoundException();
53
        }
54
55 25
        return $this->parentDefinition;
56
    }
57
}
58