Skip to content

Commit 70f2a1c

Browse files
committed
refactor(ApiResponse): Update json method parameters
- Changed the type of the $status parameter to accept boolean, integer, or string values. - This increases flexibility in handling various status code representations. - Adjusted method signature for better readability by aligning parameters.
1 parent 1952fa9 commit 70f2a1c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/ApiResponse.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,13 @@ public function exception(\Throwable $throwable): JsonResponse
9191
* @param int<100, 599>|int<100000, 599999> $code
9292
* @param null|array<string, mixed> $error
9393
*/
94-
public function json(bool $status, int $code, string $message = '', mixed $data = null, ?array $error = null): JsonResponse
95-
{
94+
public function json(
95+
bool|int|string $status,
96+
int $code,
97+
string $message = '',
98+
mixed $data = null,
99+
?array $error = null
100+
): JsonResponse {
96101
return $this
97102
->newPipeline()
98103
->send([

src/Facades/ApiResponseFacade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @method static \Illuminate\Http\JsonResponse success(mixed $data = null, string $message = '', int $code = 200)
2323
* @method static \Illuminate\Http\JsonResponse error(string $message = '', int $code = 400, array|null $error = null)
2424
* @method static \Illuminate\Http\JsonResponse exception(\Throwable $throwable)
25-
* @method static \Illuminate\Http\JsonResponse json(bool $status, int $code, string $message = '', mixed $data = null, null|array $error = null)
25+
* @method static \Illuminate\Http\JsonResponse json(string|int|bool $status, int $code, string $message = '', mixed $data = null, null|array $error = null)
2626
* @method static \Guanguans\LaravelApiResponse\ApiResponse castToNull()
2727
* @method static \Guanguans\LaravelApiResponse\ApiResponse castToInteger()
2828
* @method static \Guanguans\LaravelApiResponse\ApiResponse castToFloat()

0 commit comments

Comments
 (0)