Skip to content

Commit 4c23013

Browse files
committed
Update code on GraphViz exporter based on Scrutinizer analysis.
1 parent 9938e31 commit 4c23013

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

src/Exporter/Gv.php

+23-22
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,29 @@ class Gv implements ExporterInterface
3232
*/
3333
public function export(NodeInterface $node): string
3434
{
35-
$attributes = [];
36-
foreach ($this->attributes as $key => $attribute) {
37-
if (\is_string($attribute)) {
38-
$attributes[] = \sprintf(
39-
' %s = %s',
40-
$key,
41-
$attribute
42-
);
43-
44-
continue;
45-
}
46-
47-
if (\is_array($attribute)) {
48-
$attributes[] = \sprintf(
49-
' %s %s',
50-
$key,
51-
$this->attributesArrayToText($attribute)
52-
);
53-
54-
continue;
55-
}
56-
}
35+
$attributes = \array_map(
36+
function ($key, $data) {
37+
if (\is_string($data)) {
38+
return \sprintf(
39+
' %s = %s',
40+
$key,
41+
$data
42+
);
43+
}
44+
45+
if (\is_array($data)) {
46+
return \sprintf(
47+
' %s %s',
48+
$key,
49+
$this->attributesArrayToText($data)
50+
);
51+
}
52+
53+
return null;
54+
},
55+
\array_keys($this->attributes),
56+
$this->attributes
57+
);
5758

5859
$nodes = [];
5960
foreach ($node->all() as $child) {

0 commit comments

Comments
 (0)