Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Oct 11, 2023
1 parent 4f9dc62 commit e0ca188
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions config/response.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
'code' => ['alias' => 'code', 'show' => true],
'message' => ['alias' => 'message', 'show' => true],
'error' => ['alias' => 'error', 'show' => true],
'data' => ['alias' => 'data', 'show' => true,],
'data.data' => ['alias' => 'data.data', 'show' => true,],// rows/items/list
'data' => ['alias' => 'data', 'show' => true],
'data.data' => ['alias' => 'data.data', 'show' => true], // rows/items/list
],
],
];
8 changes: 4 additions & 4 deletions src/Support/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function jsonResource(JsonResource $resource): array
{
$data = array_merge_recursive($resource->resolve(request()), $resource->with(request()), $resource->additional);

return fractal()->item($data, fn() => $data)->serializeWith(ArraySerializer::class)->toArray();
return fractal()->item($data, fn () => $data)->serializeWith(ArraySerializer::class)->toArray();
}

/**
Expand All @@ -118,7 +118,7 @@ public function jsonResource(JsonResource $resource): array
*/
protected function formatMessage(int $code, ?string $message): ?string
{
if (!$message && class_exists($enumClass = Config::get('response.enum'))) {
if (! $message && class_exists($enumClass = Config::get('response.enum'))) {
$message = $enumClass::fromValue($code)->description;
}

Expand Down Expand Up @@ -194,7 +194,7 @@ protected function formatDataFields(array $data): array
$formatConfig = \config('response.format.config', []);

foreach ($formatConfig as $key => $config) {
if (!Arr::has($data, $key)) {
if (! Arr::has($data, $key)) {
continue;
}

Expand All @@ -207,7 +207,7 @@ protected function formatDataFields(array $data): array
$key = $alias;
}

if (!$show) {
if (! $show) {
$data = Arr::except($data, $key);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Support/Traits/JsonResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Pagination\AbstractCursorPaginator;
use Illuminate\Pagination\AbstractPaginator;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Config;

Expand Down Expand Up @@ -207,6 +206,6 @@ public function success($data = [], string $message = '', int $code = 200, array
default => Arr::wrap($data)
};

return $this->formatter->response($this->formatter->format($data,$message,$code), $code, $headers, $option);
return $this->formatter->response($this->formatter->format($data, $message, $code), $code, $headers, $option);
}
}
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function defineEnvironment($app)
$app['config']->set('response.enum', \Jiannei\Response\Laravel\Tests\Repositories\Enums\ResponseCodeEnum::class);
if ($this instanceof FormatTest) {
$app['config']->set('response.format', [
'class' => \Jiannei\Response\Laravel\Tests\Support\Format::class
'class' => \Jiannei\Response\Laravel\Tests\Support\Format::class,
]);
}
}
Expand Down

0 comments on commit e0ca188

Please sign in to comment.