Completed
Push — master ( 4ef413...ae21b4 )
by Дмитрий
03:04
created

ScopePointer::isClosure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 1
cts 1
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\ClosureDefinition;
10
use PHPSA\Definition\FunctionDefinition;
11
12
/**
13
 * A pointer to the object in which we currently operate
14
 */
15
class ScopePointer
16
{
17
    /**
18
     * @var ClassMethod|FunctionDefinition
19
     */
20
    protected $object;
21
22
    /**
23
     * Initializes the scopePointer with an object
24
     *
25
     * @param $object
26 50
     */
27
    public function __construct($object)
28 50
    {
29 50
        $this->object = $object;
30
    }
31
32
    /**
33
     * Is the object a class method?
34
     *
35
     * @return bool
36 41
     */
37
    public function isClassMethod()
38 41
    {
39
        return $this->object instanceof ClassMethod;
40
    }
41
42
    /**
43
     * Is the object a closure?
44
     *
45
     * @return bool
46 6
     */
47
    public function isClosure()
48 6
    {
49
        return $this->object instanceof ClosureDefinition;
50
    }
51
52
    /**
53
     * Is the object a function?
54
     *
55
     * @return bool
56 38
     */
57
    public function isFunction()
58 38
    {
59
        return $this->object instanceof FunctionDefinition;
60
    }
61
62
    /**
63
     * Returns the object.
64
     *
65
     * @return ClassMethod|FunctionDefinition
66
     */
67
    public function getObject()
68
    {
69
        return $this->object;
70
    }
71
}
72