| Total Complexity | 3 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class ApiResponse |
||
| 8 | { |
||
| 9 | public static function error(string $message, int $code = 400, array $data = []): JsonResponse |
||
| 10 | { |
||
| 11 | $response = array_merge([ |
||
| 12 | 'success' => false, |
||
| 13 | 'message' => $message, |
||
| 14 | ], $data); |
||
| 15 | |||
| 16 | return response()->json($response, $code, [], JSON_UNESCAPED_SLASHES); |
||
| 17 | } |
||
| 18 | |||
| 19 | public static function success(?string $message, array $data = []): JsonResponse |
||
| 20 | { |
||
| 21 | $response = array_merge([ |
||
| 22 | 'success' => true, |
||
| 23 | 'message' => $message, |
||
| 24 | ], $data); |
||
| 25 | |||
| 26 | return response()->json($response, 200, [], JSON_UNESCAPED_SLASHES); |
||
| 27 | } |
||
| 28 | |||
| 29 | public static function errorAccess(string $message): JsonResponse |
||
| 32 | } |
||
| 33 | } |
||
| 34 |