@@ -48,18 +48,10 @@ public function export(NodeInterface $node): string
48
48
}
49
49
50
50
if (\is_array ($ attribute )) {
51
- $ attributesText = \array_map (
52
- static function ($ key , $ value ) {
53
- return \sprintf ('%s="%s" ' , $ key , $ value );
54
- },
55
- \array_keys ($ attribute ),
56
- $ attribute
57
- );
58
-
59
51
$ attributes .= \sprintf (
60
52
' %s %s ' . "\n" ,
61
53
$ key ,
62
- ' [ ' . \implode ( ' ' , $ attributesText ) . ' ] '
54
+ $ this -> attributesArrayToText ( $ attribute )
63
55
);
64
56
65
57
continue ;
@@ -131,6 +123,28 @@ public function setGraphAttributes(array $attributes): Gv
131
123
return $ this ;
132
124
}
133
125
126
+ /**
127
+ * Converts an attributes array to string.
128
+ *
129
+ * @param array $attributes
130
+ * The attributes.
131
+ *
132
+ * @return string
133
+ * The attributes as string.
134
+ */
135
+ protected function attributesArrayToText (array $ attributes ): string
136
+ {
137
+ $ attributesText = \array_map (
138
+ static function ($ key , $ value ) {
139
+ return \sprintf ('%s="%s" ' , $ key , $ value );
140
+ },
141
+ \array_keys ($ attributes ),
142
+ $ attributes
143
+ );
144
+
145
+ return '[ ' . \implode (' ' , $ attributesText ) . '] ' ;
146
+ }
147
+
134
148
/**
135
149
* Recursively find all the edges in a tree.
136
150
*
@@ -213,14 +227,6 @@ protected function getNodeAttributes(NodeInterface $node): string
213
227
}
214
228
}
215
229
216
- $ attributesText = \array_map (
217
- static function ($ key , $ value ) {
218
- return \sprintf ('%s="%s" ' , $ key , $ value );
219
- },
220
- \array_keys ($ attributes ),
221
- $ attributes
222
- );
223
-
224
- return '[ ' . \implode (' ' , $ attributesText ) . '] ' ;
230
+ return $ this ->attributesArrayToText ($ attributes );
225
231
}
226
232
}
0 commit comments