File tree 5 files changed +23
-14
lines changed
5 files changed +23
-14
lines changed Original file line number Diff line number Diff line change 4
4
5
5
namespace drupol \phptree \Exporter ;
6
6
7
- use drupol \phptree \Node \ValueNodeInterface ;
7
+ use drupol \phptree \Node \NodeInterface ;
8
8
9
9
/**
10
10
* Class Ascii
@@ -14,7 +14,7 @@ class Ascii implements ExporterInterface
14
14
/**
15
15
* {@inheritdoc}
16
16
*/
17
- public function export (ValueNodeInterface $ node ): string
17
+ public function export (NodeInterface $ node ): string
18
18
{
19
19
$ tree = new \RecursiveTreeIterator (
20
20
new \RecursiveArrayIterator (
@@ -51,7 +51,7 @@ public function export(ValueNodeInterface $node): string
51
51
* @return array
52
52
* The tree exported into an array.
53
53
*/
54
- private function doExportAsArray (ValueNodeInterface $ node ): array
54
+ private function doExportAsArray (NodeInterface $ node ): array
55
55
{
56
56
$ children = [];
57
57
/** @var ValueNodeInterface $child */
Original file line number Diff line number Diff line change 4
4
5
5
namespace drupol \phptree \Exporter ;
6
6
7
- use drupol \phptree \Node \ValueNodeInterface ;
7
+ use drupol \phptree \Node \NodeInterface ;
8
8
9
9
/**
10
10
* Interface ExporterInterface
@@ -14,11 +14,11 @@ interface ExporterInterface
14
14
/**
15
15
* Export a node into something.
16
16
*
17
- * @param \drupol\phptree\Node\ValueNodeInterface $node
17
+ * @param NodeInterface $node
18
18
* The node.
19
19
*
20
20
* @return mixed
21
21
* The node exported.
22
22
*/
23
- public function export (ValueNodeInterface $ node );
23
+ public function export (NodeInterface $ node );
24
24
}
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public function getTraverser(): TraverserInterface
61
61
/**
62
62
* {@inheritdoc}
63
63
*/
64
- public function export (ValueNodeInterface $ node ): OriginalGraph
64
+ public function export (NodeInterface $ node ): OriginalGraph
65
65
{
66
66
foreach ($ this ->getTraverser ()->traverse ($ node ) as $ node_visited ) {
67
67
/** @var int $vertexId */
@@ -95,9 +95,18 @@ protected function createVertex(NodeInterface $node): Vertex
95
95
/** @var int $vertexId */
96
96
$ vertexId = $ this ->createVertexId ($ node );
97
97
98
- return false === $ this ->getGraph ()->hasVertex ($ vertexId ) ?
99
- $ this ->getGraph ()->createVertex ($ vertexId ):
100
- $ vertex = $ this ->getGraph ()->getVertex ($ vertexId );
98
+ if (false === $ this ->getGraph ()->hasVertex ($ vertexId )) {
99
+ $ vertex = $ this ->getGraph ()->createVertex ($ vertexId );
100
+
101
+ $ label = NULL ;
102
+ if (method_exists ($ node , 'getValue ' )) {
103
+ $ label = $ node ->getValue ();
104
+ }
105
+
106
+ $ vertex ->setAttribute ('graphviz.label ' , $ label );
107
+ }
108
+
109
+ return $ this ->getGraph ()->getVertex ($ vertexId );
101
110
}
102
111
103
112
/**
Original file line number Diff line number Diff line change 4
4
5
5
namespace drupol \phptree \Exporter ;
6
6
7
- use drupol \phptree \Node \ValueNodeInterface ;
7
+ use drupol \phptree \Node \NodeInterface ;
8
8
9
9
/**
10
10
* Class SimpleArray
@@ -14,7 +14,7 @@ class SimpleArray implements ExporterInterface
14
14
/**
15
15
* {@inheritdoc}
16
16
*/
17
- public function export (ValueNodeInterface $ node )
17
+ public function export (NodeInterface $ node )
18
18
{
19
19
$ children = [];
20
20
/** @var ValueNodeInterface $child */
Original file line number Diff line number Diff line change 4
4
5
5
namespace drupol \phptree \Exporter ;
6
6
7
- use drupol \phptree \Node \ValueNodeInterface ;
7
+ use drupol \phptree \Node \NodeInterface ;
8
8
9
9
/**
10
10
* Class Text
@@ -14,7 +14,7 @@ class Text implements ExporterInterface
14
14
/**
15
15
* {@inheritdoc}
16
16
*/
17
- public function export (ValueNodeInterface $ node ): string
17
+ public function export (NodeInterface $ node ): string
18
18
{
19
19
$ children = [];
20
20
/** @var ValueNodeInterface $child */
You can’t perform that action at this time.
0 commit comments