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

UnknownClassReflection   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A mergeDepender() 0 4 2
A addDepender() 0 4 2
A getFile() 0 3 1
A getDisplayName() 0 3 1
A getDependers() 0 3 1
A __construct() 0 4 1
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