File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types = 1 );
4
+
5
+ namespace drupol \phptree \tests \Exporter ;
6
+
7
+ use drupol \phptree \Node \NodeInterface ;
8
+ use Fhaculty \Graph \Vertex ;
9
+
10
+ /**
11
+ * Class KeyValueGraph
12
+ */
13
+ class KeyValueGraph extends ValueGraph
14
+ {
15
+ /**
16
+ * {@inheritdoc}
17
+ */
18
+ protected function createVertex (NodeInterface $ node ): Vertex
19
+ {
20
+ $ vertex = parent ::createVertex ($ node );
21
+
22
+ if (\method_exists ($ node , 'getValue ' ) && \method_exists ($ node , 'getKey ' )) {
23
+ $ vertex ->setAttribute ('graphviz.label ' , $ node ->getValue ());
24
+ }
25
+
26
+ return $ vertex ;
27
+ }
28
+
29
+ /**
30
+ * {@inheritdoc}
31
+ */
32
+ protected function createVertexId (NodeInterface $ node )
33
+ {
34
+ if (\method_exists ($ node , 'getValue ' ) && \method_exists ($ node , 'getKey ' )) {
35
+ return $ node ->getKey () . $ node ->getValue ();
36
+ }
37
+
38
+ return \sha1 ((string ) parent ::createVertexId ($ node ));
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments