1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* PHP version 7.1 |
4
|
|
|
* |
5
|
|
|
* This source file is subject to the license that is bundled with this package in the file LICENSE. |
6
|
|
|
*/ |
7
|
|
|
namespace PhUml\Parser; |
8
|
|
|
|
9
|
|
|
class RelationsResolver |
10
|
|
|
{ |
11
|
42 |
|
public function resolve(Definitions $definitions): void |
12
|
|
|
{ |
13
|
42 |
|
foreach ($definitions->all() as $definition) { |
14
|
42 |
|
if ($definitions->isClass($definition)) { |
15
|
36 |
|
$this->resolveForClass($definitions, $definition); |
16
|
|
|
} else { |
17
|
42 |
|
$this->resolveForInterface($definitions, $definition); |
18
|
|
|
} |
19
|
|
|
} |
20
|
42 |
|
} |
21
|
|
|
|
22
|
36 |
|
private function resolveForClass(Definitions $definitions, array $definition): void |
23
|
|
|
{ |
24
|
36 |
|
foreach ($definitions->interfaces($definition) as $interface) { |
25
|
12 |
|
if (!$definitions->has($interface)) { |
26
|
12 |
|
$definitions->addExternalInterface($interface); |
27
|
|
|
} |
28
|
|
|
} |
29
|
36 |
|
$this->resolveParentClass($definitions, $definition); |
30
|
36 |
|
} |
31
|
|
|
|
32
|
21 |
|
private function resolveForInterface(Definitions $definitions, array $definition): void |
33
|
|
|
{ |
34
|
21 |
|
$this->resolveParentInterface($definitions, $definition); |
35
|
21 |
|
} |
36
|
|
|
|
37
|
36 |
|
private function resolveParentClass(Definitions $definitions, array $definition): void |
38
|
|
|
{ |
39
|
36 |
|
if ($definitions->hasParent($definition)) { |
40
|
12 |
|
$parent = $definitions->parent($definition); |
41
|
12 |
|
if (!$definitions->has($parent)) { |
42
|
6 |
|
$definitions->addExternalClass($parent); |
43
|
|
|
} |
44
|
|
|
} |
45
|
36 |
|
} |
46
|
|
|
|
47
|
21 |
|
private function resolveParentInterface(Definitions $definitions, array $definition): void |
48
|
|
|
{ |
49
|
21 |
|
if ($definitions->hasParent($definition)) { |
50
|
12 |
|
$parent = $definitions->parent($definition); |
51
|
12 |
|
if (!$definitions->has($parent)) { |
52
|
3 |
|
$definitions->addExternalInterface($parent); |
53
|
|
|
} |
54
|
|
|
} |
55
|
21 |
|
} |
56
|
|
|
} |
57
|
|
|
|