@@ -19,12 +19,12 @@ class ValueExporter
19
19
/**
20
20
* Converts a PHP value to a string.
21
21
*
22
- * @param mixed $value The PHP value
23
- * @param integer $depth The depth of the value to export
22
+ * @param mixed $value The PHP value
23
+ * @param integer $depth The depth of the value to export (only for internal usage)
24
24
*
25
25
* @return string The string representation of the given value
26
26
*/
27
- public function exportValue ($ value , $ depth = 0 )
27
+ public function exportValue ($ value , $ depth = 1 , $ deep = false )
28
28
{
29
29
if (is_object ($ value )) {
30
30
return sprintf ('Object(%s) ' , get_class ($ value ));
@@ -39,10 +39,17 @@ public function exportValue($value, $depth = 0)
39
39
40
40
$ a = array ();
41
41
foreach ($ value as $ k => $ v ) {
42
- $ a [] = sprintf ('%s %s => %s ' , $ indent , $ k , $ this ->exportValue ($ v , $ depth + 1 ));
42
+ if (is_array ($ v )) {
43
+ $ deep = true ;
44
+ }
45
+ $ a [] = sprintf ('%s => %s ' , $ k , $ this ->exportValue ($ v , $ depth + 1 , $ deep ));
43
46
}
44
47
45
- return sprintf ("[ \n%s%s \n%s] " , $ indent , implode (sprintf (", \n%s " , $ indent ), $ a ), $ indent );
48
+ if ($ deep ) {
49
+ return sprintf ("[ \n%s%s \n%s] " , $ indent , implode (sprintf (", \n%s " , $ indent ), $ a ), str_repeat (' ' , $ depth - 1 ));
50
+ }
51
+
52
+ return sprintf ("[%s] " , implode (', ' , $ a ));
46
53
}
47
54
48
55
if (is_resource ($ value )) {
0 commit comments