@@ 14-30 (lines=17) @@ | ||
11 | * @author Alexander Tømmerås <[email protected]> |
|
12 | * @license The MIT License |
|
13 | */ |
|
14 | class StatusCodeDecorator extends ResponseDecorator |
|
15 | { |
|
16 | /** |
|
17 | * Generate a JSON response. |
|
18 | * |
|
19 | * @param array $data |
|
20 | * @param int $status |
|
21 | * @param array $headers |
|
22 | * @return \Illuminate\Http\JsonResponse |
|
23 | */ |
|
24 | public function make(array $data, int $status, array $headers = []): JsonResponse |
|
25 | { |
|
26 | return $this->factory->make(array_merge([ |
|
27 | 'status' => $status, |
|
28 | ], $data), $status, $headers); |
|
29 | } |
|
30 | } |
|
31 |
@@ 14-30 (lines=17) @@ | ||
11 | * @author Alexander Tømmerås <[email protected]> |
|
12 | * @license The MIT License |
|
13 | */ |
|
14 | class SuccessFlagDecorator extends ResponseDecorator |
|
15 | { |
|
16 | /** |
|
17 | * Generate a JSON response. |
|
18 | * |
|
19 | * @param array $data |
|
20 | * @param int $status |
|
21 | * @param array $headers |
|
22 | * @return \Illuminate\Http\JsonResponse |
|
23 | */ |
|
24 | public function make(array $data, int $status, array $headers = []): JsonResponse |
|
25 | { |
|
26 | return $this->factory->make(array_merge([ |
|
27 | 'success' => $status >= 100 && $status < 400, |
|
28 | ], $data), $status, $headers); |
|
29 | } |
|
30 | } |
|
31 |