1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace Innmind\Compose\Visualization\Graph; |
5
|
|
|
|
6
|
|
|
use Innmind\Compose\{ |
7
|
|
|
Arguments as Args, |
8
|
|
|
Definition\Argument, |
9
|
|
|
Visualization\Node\Element |
10
|
|
|
}; |
11
|
|
|
use Innmind\Graphviz\{ |
12
|
|
|
Graph, |
13
|
|
|
Node, |
14
|
|
|
Graph\Name |
15
|
|
|
}; |
16
|
|
|
use Innmind\Colour\RGBA; |
17
|
|
|
use Innmind\Url\UrlInterface; |
18
|
|
|
use Innmind\Immutable\{ |
19
|
|
|
SetInterface, |
20
|
|
|
MapInterface, |
21
|
|
|
Str |
22
|
|
|
}; |
23
|
|
|
|
24
|
|
|
final class Arguments implements Graph |
25
|
|
|
{ |
26
|
|
|
private $graph; |
27
|
|
|
|
28
|
13 |
|
public function __construct(Args $arguments) |
29
|
|
|
{ |
30
|
13 |
|
$this->graph = $arguments->all()->reduce( |
31
|
13 |
|
Graph\Graph::directed('arguments') |
32
|
13 |
|
->fillWithColor(RGBA::fromString('#3399ff')) |
33
|
13 |
|
->displayAs('Arguments'), |
34
|
13 |
|
static function(Graph $graph, Argument $argument): Graph { |
35
|
13 |
|
return $graph->add(Element::argument($argument)); |
36
|
13 |
|
} |
37
|
|
|
); |
38
|
13 |
|
} |
39
|
|
|
|
40
|
2 |
|
public function isDirected(): bool |
41
|
|
|
{ |
42
|
2 |
|
return $this->graph->isDirected(); |
43
|
|
|
} |
44
|
|
|
|
45
|
2 |
|
public function name(): Name |
46
|
|
|
{ |
47
|
2 |
|
return $this->graph->name(); |
48
|
|
|
} |
49
|
|
|
|
50
|
1 |
|
public function cluster(Graph $cluster): Graph |
51
|
|
|
{ |
52
|
1 |
|
return $this->graph->cluster($cluster); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
2 |
|
public function clusters(): SetInterface |
59
|
|
|
{ |
60
|
2 |
|
return $this->graph->clusters(); |
61
|
|
|
} |
62
|
|
|
|
63
|
1 |
|
public function add(Node $node): Graph |
64
|
|
|
{ |
65
|
1 |
|
return $this->graph->add($node); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
4 |
|
public function roots(): SetInterface |
72
|
|
|
{ |
73
|
4 |
|
return $this->graph->roots(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* {@inheritdoc} |
78
|
|
|
*/ |
79
|
2 |
|
public function nodes(): SetInterface |
80
|
|
|
{ |
81
|
2 |
|
return $this->graph->nodes(); |
82
|
|
|
} |
83
|
|
|
|
84
|
1 |
|
public function displayAs(string $label): Graph |
85
|
|
|
{ |
86
|
1 |
|
return $this->graph->displayAs($label); |
87
|
|
|
} |
88
|
|
|
|
89
|
1 |
|
public function fillWithColor(RGBA $color): Graph |
90
|
|
|
{ |
91
|
1 |
|
return $this->graph->fillWithColor($color); |
92
|
|
|
} |
93
|
|
|
|
94
|
1 |
|
public function colorizeBorderWith(RGBA $color): Graph |
95
|
|
|
{ |
96
|
1 |
|
return $this->graph->colorizeBorderWith($color); |
97
|
|
|
} |
98
|
|
|
|
99
|
1 |
|
public function target(UrlInterface $url): Graph |
100
|
|
|
{ |
101
|
1 |
|
return $this->graph->target($url); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* {@inheritdoc} |
106
|
|
|
*/ |
107
|
6 |
|
public function attributes(): MapInterface |
108
|
|
|
{ |
109
|
6 |
|
return $this->graph->attributes(); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|