@@ -30,25 +30,26 @@ function ($acc, $key) use ($tree, $replacer, $spacesCount, $depth) {
30
30
$ indentationCount = $ spacesCount * $ depth - 2 ;
31
31
$ indentation = str_repeat ($ replacer , $ indentationCount );
32
32
33
- if (array_key_exists ('value ' , $ keyData )) {
34
- $ value = $ keyData ['value ' ];
35
-
36
- if (!is_array ($ value )) {
37
- $ string = getStylishString ($ status , $ key , $ value , $ indentation );
38
- return "{$ resultString }{$ string }" ;
39
- }
33
+ if (array_key_exists ('children ' , $ keyData )) {
34
+ $ value = $ keyData ['children ' ];
40
35
41
36
if ($ status === ADD_MARKER ) {
42
37
$ innerContent = getArrayContent ($ value , $ replacer , $ spacesCount , $ depth + 1 );
43
38
$ string = getStylishInnerContent ($ status , $ key , $ innerContent , $ indentation );
44
39
return "{$ resultString }{$ string }" ;
45
40
}
46
41
47
- $ innerContent = getStylish ($ keyData [ ' value ' ] , $ replacer , $ spacesCount , $ depth + 1 );
42
+ $ innerContent = getStylish ($ value , $ replacer , $ spacesCount , $ depth + 1 );
48
43
$ string = getStylishInnerContent ($ status , $ key , $ innerContent , $ indentation );
49
44
return "{$ resultString }{$ string }" ;
50
45
}
51
46
47
+ if (array_key_exists ('value ' , $ keyData )) {
48
+ $ value = $ keyData ['value ' ];
49
+ $ string = getStylishString ($ status , $ key , $ value , $ indentation );
50
+ return "{$ resultString }{$ string }" ;
51
+ }
52
+
52
53
$ data = [
53
54
'indentation ' => $ indentation ,
54
55
'replacer ' => $ replacer ,
@@ -79,16 +80,17 @@ function ($acc, $key) use ($tree, $replacer, $spacesCount, $depth) {
79
80
function getArrayContent (array $ tree , string $ replacer , int $ spacesCount , int $ depth ): string
80
81
{
81
82
return array_reduce (array_keys ($ tree ), function ($ acc , $ key ) use ($ tree , $ replacer , $ spacesCount , $ depth ) {
82
- $ value = $ tree [$ key ]['value ' ];
83
83
$ indentationCount = $ spacesCount * $ depth - 2 ;
84
84
$ indentation = str_repeat ($ replacer , $ indentationCount );
85
85
$ resultString = $ acc ;
86
86
87
- if (!is_array ($ value )) {
87
+ if (array_key_exists ('value ' , $ tree [$ key ])) {
88
+ $ value = $ tree [$ key ]['value ' ];
88
89
$ string = getStylishString (UNCHANGED_MARKER , $ key , $ value , $ indentation );
89
90
return "{$ resultString }{$ string }" ;
90
91
}
91
92
93
+ $ value = $ tree [$ key ]['children ' ];
92
94
$ innerContent = getArrayContent ($ value , $ replacer , $ spacesCount , $ depth + 1 );
93
95
return getStylishInnerContent (UNCHANGED_MARKER , $ key , $ innerContent , $ indentation );
94
96
}, '' );
0 commit comments