Passed
Push — master ( 056350...65484c )
by Satoshi
05:02
created

PropertyFetch::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace DependencyAnalyzer\DependencyGraph\DependencyTypes;
5
6
use DependencyAnalyzer\DependencyGraph;
7
8
class PropertyFetch extends Base
9
{
10
    /**
11
     * @var string
12
     */
13
    private $propertyName;
14
    /**
15
     * @var string
16
     */
17
    private $caller;
18
19
    public function __construct(string $propertyName, string $caller = null)
20
    {
21
        $this->propertyName = $propertyName;
22
        $this->caller = $caller;
23
    }
24
25
    public function getPropertyName(): string
26
    {
27
        return $this->propertyName;
28
    }
29
30
    public function getCaller(): ?string
31
    {
32
        return $this->caller;
33
    }
34
35
    public function getType(): string
36
    {
37
        return DependencyGraph::TYPE_PROPERTY_FETCH;
38
    }
39
40
    public function isEqual(Base $that): bool
41
    {
42
        return (
43
            $that instanceof self &&
44
            $this->getPropertyName() === $that->getPropertyName() &&
45
            $this->getCaller() === $that->getCaller()
46
        );
47
    }
48
49
    public function toString(): string
50
    {
51
        $ret = "{$this->getType()}:{$this->getPropertyName()}";
52
        if ($this->getCaller()) {
53
            $ret .= ":{$this->getCaller()}";
54
        }
55
56
        return $ret;
57
    }
58
}
59