File tree 2 files changed +9
-1
lines changed
spec/drupol/phptree/Exporter
2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 6
6
7
7
use drupol \phptree \Exporter \Graph ;
8
8
use drupol \phptree \Importer \Text ;
9
+ use drupol \phptree \Node \AttributeNode ;
9
10
use drupol \phptree \Node \ValueNode ;
10
11
use Graphp \GraphViz \GraphViz ;
11
12
use PhpSpec \ObjectBehavior ;
@@ -36,7 +37,7 @@ public function getMatchers(): array
36
37
37
38
public function it_can_generate_a_graph ()
38
39
{
39
- $ tree = new ValueNode ( ' root ' );
40
+ $ tree = new AttributeNode ([ ' graphviz.label ' => ' root '] );
40
41
$ child1 = new ValueNode ('child1 ' );
41
42
$ child2 = new ValueNode ('child2 ' );
42
43
$ child3 = new ValueNode ('child3 ' );
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 \AttributeNodeInterface ;
7
8
use drupol \phptree \Node \NodeInterface ;
8
9
use drupol \phptree \Node \ValueNodeInterface ;
9
10
use Fhaculty \Graph \Graph as OriginalGraph ;
@@ -61,6 +62,12 @@ protected function createVertex(NodeInterface $node): Vertex
61
62
if ($ node instanceof ValueNodeInterface) {
62
63
$ vertex ->setAttribute ('graphviz.label ' , $ node ->getValue ());
63
64
}
65
+
66
+ if ($ node instanceof AttributeNodeInterface) {
67
+ foreach ($ node ->getAttributes () as $ key => $ value ) {
68
+ $ vertex ->setAttribute ($ key , $ value );
69
+ }
70
+ }
64
71
}
65
72
66
73
return $ this ->getGraph ()->getVertex ($ vertexId );
You can’t perform that action at this time.
0 commit comments