AbstractMethodBodyBuilder::setInstance()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * @author stev leibelt <[email protected]>
4
 * @since 2014-06-12 
5
 */
6
7
namespace Net\Bazzline\Component\Locator\MethodBodyBuilder;
8
9
use Net\Bazzline\Component\CodeGenerator\DocumentationGenerator;
10
use Net\Bazzline\Component\Locator\Configuration\Instance;
11
12
/**
13
 * Class AbstractMethodBodyBuilder
14
 * @package Net\Bazzline\Component\Locator\MethodBodyBuilder
15
 */
16
abstract class AbstractMethodBodyBuilder implements MethodBodyBuilderInterface
17
{
18
    /** @var Instance */
19
    protected $instance;
20
21
    public function __clone()
22
    {
23
        $this->instance = null;
24
    }
25
26
    /**
27
     * @param Instance $instance
28
     * @return $this
29
     */
30
    public function setInstance(Instance $instance)
31
    {
32
        $this->instance = $instance;
33
34
        return $this;
35
    }
36
37
    /**
38
     * @param DocumentationGenerator $documentation
39
     * @return DocumentationGenerator
40
     */
41
    public function extend(DocumentationGenerator $documentation)
42
    {
43
        return $documentation;
44
    }
45
46
    /**
47
     * @param array $propertyNames
48
     * @throws RuntimeException
49
     */
50
    protected function assertMandatoryProperties(array $propertyNames = array('instance'))
51
    {
52
        foreach ($propertyNames as $propertyName) {
53
            if (!isset($this->$propertyName)
54
                || (is_null($this->$propertyName))) {
55
                throw new RuntimeException(
56
                    'property "' . $propertyName . '" is mandatory'
57
                );
58
            }
59
        }
60
    }
61
}