Completed
Pull Request — master (#183)
by Danny
11:52
created

ScopePointer::__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
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA;
7
8
use PHPSA\Definition\ClassMethod;
9
use PHPSA\Definition\FunctionDefinition;
10
11
/**
12
 * A pointer to the object in which we currently operate
13
 */
14
class ScopePointer
15
{
16
    /**
17
     * @var ClassMethod|FunctionDefinition
18
     */
19
    protected $object;
20
21
    /**
22
     * Initializes the scopePointer with an object
23
     *
24
     * @param $object
25
     */
26 46
    public function __construct($object)
27
    {
28 46
        $this->object = $object;
29 46
    }
30
31
    /**
32
     * Is the object a class method?
33
     *
34
     * @return bool
35
     */
36 38
    public function isClassMethod()
37
    {
38 38
        return $this->object instanceof ClassMethod;
39
    }
40
41
    /**
42
     * Is the object a function?
43
     *
44
     * @return bool
45
     */
46 6
    public function isFunction()
47
    {
48 6
        return $this->object instanceof FunctionDefinition;
49
    }
50
51
    /**
52
     * Returns the object.
53
     *
54
     * @return ClassMethod|FunctionDefinition
55
     */
56 35
    public function getObject()
57
    {
58 35
        return $this->object;
59
    }
60
}
61