Skip to content

Commit

Permalink
Update code on GraphViz exporter based on Scrutinizer analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jun 26, 2019
1 parent 9938e31 commit 4c23013
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/Exporter/Gv.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,29 @@ class Gv implements ExporterInterface
*/
public function export(NodeInterface $node): string
{
$attributes = [];
foreach ($this->attributes as $key => $attribute) {
if (\is_string($attribute)) {
$attributes[] = \sprintf(
' %s = %s',
$key,
$attribute
);

continue;
}

if (\is_array($attribute)) {
$attributes[] = \sprintf(
' %s %s',
$key,
$this->attributesArrayToText($attribute)
);

continue;
}
}
$attributes = \array_map(
function ($key, $data) {
if (\is_string($data)) {
return \sprintf(
' %s = %s',
$key,
$data
);
}

if (\is_array($data)) {
return \sprintf(
' %s %s',
$key,
$this->attributesArrayToText($data)
);
}

return null;
},
\array_keys($this->attributes),
$this->attributes
);

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

0 comments on commit 4c23013

Please sign in to comment.