@@ -19,18 +19,18 @@ public function handle(): int
19
19
$ this ->info ('Starting json structure command... ' );
20
20
21
21
// if ($this->argument('endpoint')) {
22
- $ this ->info ('Getting json structure from endpoint... ' );
22
+ $ this ->info ('Getting json structure from endpoint... ' );
23
23
24
- $ response = Http::get (route ($ this ->argument ('endpoint ' )));
24
+ $ response = Http::get (route ($ this ->argument ('endpoint ' )));
25
25
26
- if ($ response ->failed ()) {
27
- $ this ->error ('Could not get json structure from endpoint ' );
26
+ if ($ response ->failed ()) {
27
+ $ this ->error ('Could not get json structure from endpoint ' );
28
28
29
- return Command::FAILURE ;
30
- }
31
- $ this ->comment ('Getting json structure from endpoint successful ' );
29
+ return Command::FAILURE ;
30
+ }
31
+ $ this ->comment ('Getting json structure from endpoint successful ' );
32
32
33
- $ json = $ response ->json ();
33
+ $ json = $ response ->json ();
34
34
// } else {
35
35
// $this->info('Getting json structure from array...');
36
36
//
@@ -39,11 +39,12 @@ public function handle(): int
39
39
40
40
if (is_null ($ json )) {
41
41
$ this ->error ('The json structure is null ' );
42
+
42
43
return Command::FAILURE ;
43
44
}
44
45
45
46
$ this ->info ('Attempting to decode json structure... ' );
46
- $ result = '[ ' . PHP_EOL . $ this ->implode_recursive (', ' , $ this ->array_keys_r ($ json )) . PHP_EOL . '] ' . PHP_EOL ;
47
+ $ result = '[ ' . PHP_EOL . $ this ->implode_recursive (', ' , $ this ->array_keys_r ($ json )). PHP_EOL . '] ' . PHP_EOL ;
47
48
$ this ->comment ('Decoding json structure successful ' );
48
49
49
50
$ this ->info ('Writing result to file... ' );
@@ -63,7 +64,8 @@ private function array_keys_r($array): array
63
64
if ($ index = array_search ($ idx , $ keys , true )) {
64
65
unset($ keys [$ index ]);
65
66
}
66
- $ keys_array [$ idx ] = ['* ' => $ this ->array_keys_r (array_values ($ i )[0 ])];
67
+ $ keys_array [$ idx ] = ['* ' => $ this ->array_keys_r (array_values ($ i )[0 ])];
68
+
67
69
continue ;
68
70
}
69
71
if (is_array ($ i )) {
@@ -83,23 +85,23 @@ private function implode_recursive(string $separator, array $array, int $indent
83
85
foreach ($ array as $ i => $ a ) {
84
86
if (is_array ($ a )) {
85
87
$ string .= (str_repeat (' ' , $ indent ))
86
- . '\''
87
- . $ i
88
- . '\''
89
- . ' => [ '
90
- . PHP_EOL
91
- . $ this ->implode_recursive ($ separator , $ a , $ indent + 1 )
92
- . PHP_EOL
93
- . (str_repeat (' ' , $ indent ))
94
- . '] ' ;
88
+ .'\''
89
+ .$ i
90
+ .'\''
91
+ .' => [ '
92
+ .PHP_EOL
93
+ .$ this ->implode_recursive ($ separator , $ a , $ indent + 1 )
94
+ .PHP_EOL
95
+ .(str_repeat (' ' , $ indent ))
96
+ .'] ' ;
95
97
$ array1 = array_keys ($ array );
96
98
if ($ i !== end ($ array1 )) {
97
- $ string .= $ separator . PHP_EOL ;
99
+ $ string .= $ separator. PHP_EOL ;
98
100
}
99
101
} else {
100
- $ string .= (str_repeat (' ' , $ indent )) . '\'' . $ a . '\'' ;
102
+ $ string .= (str_repeat (' ' , $ indent )). '\'' . $ a . '\'' ;
101
103
if ($ i < count ($ array ) - 1 ) {
102
- $ string .= $ separator . PHP_EOL ;
104
+ $ string .= $ separator. PHP_EOL ;
103
105
}
104
106
}
105
107
}
@@ -109,14 +111,15 @@ private function implode_recursive(string $separator, array $array, int $indent
109
111
110
112
private function is_array_of_arrays ($ array ): bool
111
113
{
112
- if (!is_array ($ array )) {
114
+ if (! is_array ($ array )) {
113
115
return false ;
114
116
}
115
117
foreach ($ array as $ item ) {
116
- if (!is_array ($ item )) {
118
+ if (! is_array ($ item )) {
117
119
return false ;
118
120
}
119
121
}
122
+
120
123
return true ;
121
124
}
122
125
}
0 commit comments