1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Koriym\AppStateDiagram; |
||
6 | |||
7 | use function assert; |
||
8 | use function count; |
||
9 | use function in_array; |
||
10 | use function sprintf; |
||
11 | |||
12 | use const PHP_EOL; |
||
13 | |||
14 | final class Edge |
||
15 | { |
||
16 | /** @var AbstractProfile */ |
||
17 | private $profile; |
||
18 | |||
19 | /** @var ?string */ |
||
20 | private $color; |
||
21 | |||
22 | /** @var ?TaggedProfile */ |
||
23 | private $taggedProfile; |
||
24 | |||
25 | public function __construct(AbstractProfile $profile, ?TaggedProfile $taggedProfile = null, ?string $color = null) |
||
26 | { |
||
27 | $this->profile = $profile; |
||
28 | $this->color = $color; |
||
29 | $this->taggedProfile = $taggedProfile; |
||
30 | } |
||
31 | |||
32 | public function __toString(): string |
||
33 | { |
||
34 | $graph = ''; |
||
35 | /** @psalm-suppress MixedArgumentTypeCoercion */ |
||
36 | $groupedLinks = $this->groupEdges($this->profile->links); |
||
37 | foreach ($groupedLinks as $link) { |
||
38 | $graph .= count($link) === 1 ? $this->singleLink($link) : $this->multipleLink($link); |
||
39 | } |
||
40 | |||
41 | return $graph; |
||
42 | } |
||
43 | |||
44 | /** @param list<Link> $links */ |
||
0 ignored issues
–
show
|
|||
45 | private function singleLink(array $links): string |
||
46 | { |
||
47 | $link = $links[0]; |
||
48 | $base = ' %s -> %s [label = <%s> URL="docs/%s.%s.html" target="_parent" fontsize=13'; |
||
49 | |||
50 | if (! isset($this->color, $this->taggedProfile)) { |
||
51 | return sprintf($base . '];' . PHP_EOL, $link->from, $link->to, $link->label, $link->transDescriptor->type, $link->transDescriptor->id); |
||
52 | } |
||
53 | |||
54 | if (in_array($link, $this->taggedProfile->links)) { |
||
55 | return sprintf($base . ' color="%s"];' . PHP_EOL, $link->from, $link->to, $link->label, $link->transDescriptor->type, $link->transDescriptor->id, $this->color); |
||
56 | } |
||
57 | |||
58 | return sprintf($base . '];' . PHP_EOL, $link->from, $link->to, $link->label, $link->transDescriptor->type, $link->transDescriptor->id); |
||
59 | } |
||
60 | |||
61 | /** @param list<Link> $links */ |
||
62 | private function multipleLink(array $links): string |
||
63 | { |
||
64 | assert(isset($links[0])); |
||
65 | $trs = ''; |
||
66 | foreach ($links as $link) { |
||
67 | $trs .= sprintf('<tr><td align="left" href="docs/%s.%s.html" tooltip="%s (%s)" >%s (%s)</td></tr>', $link->transDescriptor->type, $link->transDescriptor->id, $link->transDescriptor->id, $link->transDescriptor->type, $link->transDescriptor->id, $link->transDescriptor->type); |
||
68 | } |
||
69 | |||
70 | $base = ' %s -> %s [label=<<table border="0">%s</table>> fontsize=13'; |
||
71 | |||
72 | if (! isset($this->color, $this->taggedProfile)) { |
||
73 | return sprintf($base . '];' . PHP_EOL, $links[0]->from, $links[0]->to, $trs); |
||
74 | } |
||
75 | |||
76 | foreach ($links as $link) { |
||
77 | if (in_array($link, $this->taggedProfile->links)) { |
||
78 | return sprintf($base . ' color="%s"];' . PHP_EOL, $links[0]->from, $links[0]->to, $trs, $this->color); |
||
79 | } |
||
80 | } |
||
81 | |||
82 | return sprintf($base . '];' . PHP_EOL, $links[0]->from, $links[0]->to, $trs); |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @param array<string, Link> $links |
||
87 | * |
||
88 | * @return array<string, list<Link>> |
||
0 ignored issues
–
show
|
|||
89 | */ |
||
90 | private function groupEdges(array $links): array |
||
91 | { |
||
92 | $groupedLinks = []; |
||
93 | foreach ($links as $link) { |
||
94 | $fromTo = $link->from . $link->to; |
||
95 | $groupedLinks[$fromTo][] = $link; |
||
96 | } |
||
97 | |||
98 | return $groupedLinks; |
||
99 | } |
||
100 | } |
||
101 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths