Passed
Push — master ( c57dde...29e061 )
by Satoshi
02:16
created

UnknownClassReflection::addDepender()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace DependencyAnalyzer\DependencyGraphBuilder;
5
6
class UnknownClassReflection
7
{
8
    /**
9
     * @var string
10
     */
11
    private $className;
12
13
    /**
14
     * @var string
15
     */
16
    private $file;
17
18
    /**
19
     * @var string[]
20
     */
21
    private $dependerNames = [];
22
23
    public function __construct(string $className, string $file = null)
24
    {
25
        $this->className = $className;
26
        $this->file = $file;
27
    }
28
29
    public function getDisplayName(): string
30
    {
31
        return $this->className;
32
    }
33
34
    public function getFile(): ?string
35
    {
36
        $this->file;
37
    }
38
39
    public function getDependers()
40
    {
41
        return $this->dependerNames;
42
    }
43
44
    public function addDepender(string $className): void
45
    {
46
        if (!in_array($className, $this->dependerNames)) {
47
            $this->dependerNames[] = $className;
48
        }
49
    }
50
51
    public function mergeDepender(UnknownClassReflection $that)
52
    {
53
        foreach ($that->getDependers() as $depender) {
54
            $this->addDepender($depender);
55
        }
56
    }
57
}
58