Skip to content

Commit 9940b9a

Browse files
committed
Update documentation and code style.
1 parent f75af46 commit 9940b9a

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/Exporter/Gv.php

+21-13
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ class Gv implements ExporterInterface
3232
*/
3333
public function export(NodeInterface $node): string
3434
{
35-
$attributes = '';
35+
$attributes = [];
3636
foreach ($this->attributes as $key => $attribute) {
3737
if (\is_string($attribute)) {
38-
$attributes .= \sprintf(
39-
' %s = %s' . "\n",
38+
$attributes[] = \sprintf(
39+
' %s = %s',
4040
$key,
4141
$attribute
4242
);
@@ -45,8 +45,8 @@ public function export(NodeInterface $node): string
4545
}
4646

4747
if (\is_array($attribute)) {
48-
$attributes .= \sprintf(
49-
' %s %s' . "\n",
48+
$attributes[] = \sprintf(
49+
' %s %s',
5050
$key,
5151
$this->attributesArrayToText($attribute)
5252
);
@@ -55,26 +55,30 @@ public function export(NodeInterface $node): string
5555
}
5656
}
5757

58-
$nodes = '';
58+
$nodes = [];
5959
foreach ($node->all() as $child) {
60-
$nodes .= \sprintf(
61-
' "%s" %s' . "\n",
60+
$nodes[] = \sprintf(
61+
' "%s" %s',
6262
$this->getHash($child),
6363
$this->getNodeAttributes($child)
6464
);
6565
}
6666

67-
$edges = '';
67+
$edges = [];
6868
foreach ($this->findEdges($node) as $parent => $child) {
69-
$edges .= \sprintf(
70-
' "%s" %s "%s";' . "\n",
69+
$edges[] = \sprintf(
70+
' "%s" %s "%s";',
7171
$this->getHash($parent),
7272
true === $this->getDirected() ? '->' : '--',
7373
$this->getHash($child)
7474
);
7575
}
7676

77-
return $this->getGv($attributes, $nodes, $edges);
77+
return $this->getGv(
78+
implode(PHP_EOL, $attributes),
79+
implode(PHP_EOL, $nodes),
80+
implode(PHP_EOL, $edges)
81+
);
7882
}
7983

8084
/**
@@ -179,9 +183,13 @@ protected function getGv(string $attributes = '', string $nodes = '', string $ed
179183

180184
return <<<EOF
181185
{$graphType} PHPTreeGraph {
182-
186+
// The graph attributes.
183187
{$attributes}
188+
189+
// The graph nodes.
184190
{$nodes}
191+
192+
// The graph edges.
185193
{$edges}
186194
}
187195
EOF;

src/Node/TrieNode.php

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class TrieNode extends KeyValueNode
1414
*/
1515
public function add(NodeInterface ...$nodes): NodeInterface
1616
{
17+
/** @var \drupol\phptree\Node\ValueNodeInterface $node */
1718
foreach ($nodes as $node) {
1819
$data = $node->getValue();
1920

@@ -47,6 +48,7 @@ public function add(NodeInterface ...$nodes): NodeInterface
4748
*/
4849
private function append(ValueNodeInterface $node)
4950
{
51+
/** @var \drupol\phptree\Node\ValueNodeInterface $child */
5052
foreach ($this->children() as $child) {
5153
if ($node->getValue() === $child->getValue()) {
5254
return $child;

0 commit comments

Comments
 (0)