Skip to content

Commit e43a16c

Browse files
committed
Update Exporters, remove obsolete AbstractExporter.
1 parent 29f04e9 commit e43a16c

File tree

7 files changed

+23
-50
lines changed

7 files changed

+23
-50
lines changed

src/Exporter/AbstractExporter.php

-27
This file was deleted.

src/Exporter/Ascii.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Class Ascii.
1717
*/
18-
final class Ascii extends AbstractExporter
18+
final class Ascii implements ExporterInterface
1919
{
2020
/**
2121
* {@inheritdoc}
@@ -69,7 +69,7 @@ private function doExportAsArray(NodeInterface $node): array
6969
}
7070

7171
return [] === $children ?
72-
[$this->getNodeRepresentation($node)] :
73-
[$this->getNodeRepresentation($node), $children];
72+
[$node->label()] :
73+
[$node->label(), $children];
7474
}
7575
}

src/Exporter/Graph.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* Class Graph.
1414
*/
15-
final class Graph extends AbstractExporter
15+
final class Graph implements ExporterInterface
1616
{
1717
/**
1818
* The graph.
@@ -49,7 +49,7 @@ public function export(NodeInterface $node): OriginalGraph
4949
* @return \Fhaculty\Graph\Vertex
5050
* A vertex
5151
*/
52-
protected function createVertex(NodeInterface $node): Vertex
52+
private function createVertex(NodeInterface $node): Vertex
5353
{
5454
/** @var int $vertexId */
5555
$vertexId = $this->createVertexId($node);
@@ -59,7 +59,7 @@ protected function createVertex(NodeInterface $node): Vertex
5959

6060
$vertex->setAttribute(
6161
'graphviz.label',
62-
$this->getNodeRepresentation($node)
62+
$node->label()
6363
);
6464

6565
if ($node instanceof AttributeNodeInterface) {
@@ -78,18 +78,18 @@ protected function createVertex(NodeInterface $node): Vertex
7878
* @param \loophp\phptree\Node\NodeInterface $node
7979
* The node
8080
*
81-
* @return int|string|null
81+
* @return string
8282
* A vertex ID
8383
*/
84-
protected function createVertexId(NodeInterface $node)
84+
private function createVertexId(NodeInterface $node): string
8585
{
8686
return spl_object_hash($node);
8787
}
8888

8989
/**
9090
* @return \Fhaculty\Graph\Graph
9191
*/
92-
protected function getGraph(): OriginalGraph
92+
private function getGraph(): OriginalGraph
9393
{
9494
return $this->graph;
9595
}

src/Exporter/Gv.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Class Gv.
1717
*/
18-
final class Gv extends AbstractExporter
18+
final class Gv implements ExporterInterface
1919
{
2020
/**
2121
* The graph attributes.
@@ -136,7 +136,7 @@ public function setGraphAttributes(array $attributes): self
136136
* @return string
137137
* The attributes as string.
138138
*/
139-
protected function attributesArrayToText(array $attributes): string
139+
private function attributesArrayToText(array $attributes): string
140140
{
141141
$attributesText = array_filter(
142142
array_map(
@@ -166,7 +166,7 @@ static function ($key, $value) {
166166
* @return Generator<NodeInterface, NodeInterface>
167167
* Yield the parent and child node.
168168
*/
169-
protected function findEdges(NodeInterface $node): iterable
169+
private function findEdges(NodeInterface $node): iterable
170170
{
171171
foreach ($node->children() as $child) {
172172
yield $node => $child;
@@ -186,7 +186,7 @@ protected function findEdges(NodeInterface $node): iterable
186186
* @return string
187187
* The content of the .gv file.
188188
*/
189-
protected function getGv(string $attributes = '', string $nodes = '', string $edges = ''): string
189+
private function getGv(string $attributes = '', string $nodes = '', string $edges = ''): string
190190
{
191191
$graphType = $this->getDirected() ?
192192
'digraph' :
@@ -215,7 +215,7 @@ protected function getGv(string $attributes = '', string $nodes = '', string $ed
215215
* @return string
216216
* The hash of the node.
217217
*/
218-
protected function getHash(NodeInterface $node): string
218+
private function getHash(NodeInterface $node): string
219219
{
220220
return sha1(spl_object_hash($node));
221221
}
@@ -229,10 +229,10 @@ protected function getHash(NodeInterface $node): string
229229
* @return array<mixed, mixed>
230230
* The attributes as an array.
231231
*/
232-
protected function getNodeAttributes(NodeInterface $node): array
232+
private function getNodeAttributes(NodeInterface $node): array
233233
{
234234
$attributes = [
235-
'label' => $this->getNodeRepresentation($node),
235+
'label' => $node->label(),
236236
];
237237

238238
if ($node instanceof AttributeNodeInterface) {

src/Exporter/Image.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* Class Image.
1414
*/
15-
final class Image extends AbstractExporter
15+
final class Image implements ExporterInterface
1616
{
1717
/**
1818
* @var string

src/Exporter/SimpleArray.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Class SimpleArray.
1313
*/
14-
final class SimpleArray extends AbstractExporter
14+
final class SimpleArray implements ExporterInterface
1515
{
1616
/**
1717
* {@inheritdoc}
@@ -29,7 +29,7 @@ public function export(NodeInterface $node)
2929
}
3030

3131
return [] === $children ?
32-
['value' => $this->getNodeRepresentation($node)] :
33-
['value' => $this->getNodeRepresentation($node), 'children' => $children];
32+
['value' => $node->label()] :
33+
['value' => $node->label(), 'children' => $children];
3434
}
3535
}

src/Exporter/Text.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* Class Text.
1212
*/
13-
final class Text extends AbstractExporter
13+
final class Text implements ExporterInterface
1414
{
1515
/**
1616
* {@inheritdoc}
@@ -25,7 +25,7 @@ public function export(NodeInterface $node): string
2525
}
2626

2727
return [] === $children ?
28-
sprintf('[%s]', $this->getNodeRepresentation($node)) :
29-
sprintf('[%s%s]', $this->getNodeRepresentation($node), implode('', $children));
28+
sprintf('[%s]', $node->label()) :
29+
sprintf('[%s%s]', $node->label(), implode('', $children));
3030
}
3131
}

0 commit comments

Comments
 (0)