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

ScopePointer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isClassMethod() 0 4 1
A getObject() 0 4 1
A isFunction() 0 4 1
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