File tree 1 file changed +14
-6
lines changed
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -138,12 +138,20 @@ public function setGraphAttributes(array $attributes): self
138
138
*/
139
139
protected function attributesArrayToText (array $ attributes ): string
140
140
{
141
- $ attributesText = array_map (
142
- static function ($ key , $ value ) {
143
- return sprintf ('%s="%s" ' , $ key , $ value );
144
- },
145
- array_keys ($ attributes ),
146
- $ attributes
141
+ $ attributesText = array_filter (
142
+ array_map (
143
+ static function ($ key , $ value ) {
144
+ if (null === $ value || is_scalar ($ value ) || method_exists ($ value , '__toString ' )) {
145
+ $ value = (string ) $ value ;
146
+ } else {
147
+ return null ;
148
+ }
149
+
150
+ return sprintf ('%s="%s" ' , $ key , $ value );
151
+ },
152
+ array_keys ($ attributes ),
153
+ $ attributes
154
+ )
147
155
);
148
156
149
157
return '[ ' . implode (' ' , $ attributesText ) . '] ' ;
You can’t perform that action at this time.
0 commit comments