ConstantFetch   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 16
c 1
b 0
f 1
dl 0
loc 49
rs 10
wmc 9

6 Methods

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