Spaces:
Sleeping

fx-craft / api /utils /Response.php
felix-fx's picture
Initial setup for fx-craft website
9694b21 verified
Raw History Blame Contribute Delete
554 Bytes
<?php
// /api/utils/Response.php
class Response {
public static function json($data, int $status = 200) {
header('Content-Type: application/json');
http_response_code($status);
echo json_encode($data);
exit;
}
public static function error(string $message, int $status = 400) {
self::json([
'success' => false,
'error' => $message
], $status);
}
public static function success($data = []) {
self::json(array_merge(['success' => true], $data));
}
}