Skip to content

Commit c6c1e10

Browse files
author
Katalam
committed
Fixing styling issues
1 parent 906802b commit c6c1e10

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

src/Commands/JsonStructureCommand.php

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ public function handle(): int
1919
$this->info('Starting json structure command...');
2020

2121
// if ($this->argument('endpoint')) {
22-
$this->info('Getting json structure from endpoint...');
22+
$this->info('Getting json structure from endpoint...');
2323

24-
$response = Http::get(route($this->argument('endpoint')));
24+
$response = Http::get(route($this->argument('endpoint')));
2525

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');
2828

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');
3232

33-
$json = $response->json();
33+
$json = $response->json();
3434
// } else {
3535
// $this->info('Getting json structure from array...');
3636
//
@@ -39,11 +39,12 @@ public function handle(): int
3939

4040
if (is_null($json)) {
4141
$this->error('The json structure is null');
42+
4243
return Command::FAILURE;
4344
}
4445

4546
$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;
4748
$this->comment('Decoding json structure successful');
4849

4950
$this->info('Writing result to file...');
@@ -63,7 +64,8 @@ private function array_keys_r($array): array
6364
if ($index = array_search($idx, $keys, true)) {
6465
unset($keys[$index]);
6566
}
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+
6769
continue;
6870
}
6971
if (is_array($i)) {
@@ -83,23 +85,23 @@ private function implode_recursive(string $separator, array $array, int $indent
8385
foreach ($array as $i => $a) {
8486
if (is_array($a)) {
8587
$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+
.']';
9597
$array1 = array_keys($array);
9698
if ($i !== end($array1)) {
97-
$string .= $separator . PHP_EOL;
99+
$string .= $separator.PHP_EOL;
98100
}
99101
} else {
100-
$string .= (str_repeat(' ', $indent)) . '\'' . $a . '\'';
102+
$string .= (str_repeat(' ', $indent)).'\''.$a.'\'';
101103
if ($i < count($array) - 1) {
102-
$string .= $separator . PHP_EOL;
104+
$string .= $separator.PHP_EOL;
103105
}
104106
}
105107
}
@@ -109,14 +111,15 @@ private function implode_recursive(string $separator, array $array, int $indent
109111

110112
private function is_array_of_arrays($array): bool
111113
{
112-
if (!is_array($array)) {
114+
if (! is_array($array)) {
113115
return false;
114116
}
115117
foreach ($array as $item) {
116-
if (!is_array($item)) {
118+
if (! is_array($item)) {
117119
return false;
118120
}
119121
}
122+
120123
return true;
121124
}
122125
}

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Hyperlink\JsonStructure\Tests;
44

5+
use Hyperlink\JsonStructure\JsonStructureServiceProvider;
56
use Illuminate\Database\Eloquent\Factories\Factory;
67
use Orchestra\Testbench\TestCase as Orchestra;
7-
use Hyperlink\JsonStructure\JsonStructureServiceProvider;
88

99
class TestCase extends Orchestra
1010
{

0 commit comments

Comments
 (0)