From e0ca188e3938a2c11e4b6667a2d1d2b9cdcbd780 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Wed, 11 Oct 2023 06:04:38 +0000 Subject: [PATCH] Apply fixes from StyleCI --- config/response.php | 4 ++-- src/Support/Format.php | 8 ++++---- src/Support/Traits/JsonResponseTrait.php | 3 +-- tests/TestCase.php | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/config/response.php b/config/response.php index d255651..5ac5189 100644 --- a/config/response.php +++ b/config/response.php @@ -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 ], ], ]; diff --git a/src/Support/Format.php b/src/Support/Format.php index 9c2d544..1073039 100644 --- a/src/Support/Format.php +++ b/src/Support/Format.php @@ -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(); } /** @@ -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; } @@ -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; } @@ -207,7 +207,7 @@ protected function formatDataFields(array $data): array $key = $alias; } - if (!$show) { + if (! $show) { $data = Arr::except($data, $key); } } diff --git a/src/Support/Traits/JsonResponseTrait.php b/src/Support/Traits/JsonResponseTrait.php index f9a4d7c..c6600e0 100644 --- a/src/Support/Traits/JsonResponseTrait.php +++ b/src/Support/Traits/JsonResponseTrait.php @@ -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; @@ -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); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 1c43831..730dbde 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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, ]); } }