Spaces:
Sleeping

File size: 554 Bytes
9694b21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?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));
    }
}