70 lines
1.6 KiB
PHP
70 lines
1.6 KiB
PHP
<?php
|
|
|
|
class mfResponse {
|
|
|
|
public static function Ok($data = []) {
|
|
$response = [];
|
|
$response['code'] = 200;
|
|
$response['status'] = "OK";
|
|
$response["data"] = $data;
|
|
return $response;
|
|
}
|
|
|
|
public static function Created($data = []) {
|
|
$response = [];
|
|
$response['code'] = 201;
|
|
$response['status'] = "Created";
|
|
$response["data"] = $data;
|
|
return $response;
|
|
}
|
|
|
|
public static function NotFound($data = []) {
|
|
$response = [];
|
|
$response['code'] = 404;
|
|
$response['status'] = "Not Found";
|
|
$response["data"] = $data;
|
|
return $response;
|
|
}
|
|
|
|
public static function BadRequest($data = []) {
|
|
$response = [];
|
|
$response['code'] = 400;
|
|
$response['status'] = "Bad Request";
|
|
$response["data"] = $data;
|
|
return $response;
|
|
}
|
|
|
|
public static function InternalServerError($data = []) {
|
|
$response = [];
|
|
$response['code'] = 500;
|
|
$response['status'] = "Internal Server Error";
|
|
$response["data"] = $data;
|
|
return $response;
|
|
}
|
|
|
|
public static function Unauthorized($data = []) {
|
|
$response = [];
|
|
$response['code'] = 401;
|
|
$response['status'] = "Unauthorized";
|
|
$response["data"] = $data;
|
|
return $response;
|
|
}
|
|
|
|
public static function Forbidden($data = []) {
|
|
$response = [];
|
|
$response['code'] = 403;
|
|
$response['status'] = "Forbidden";
|
|
$response["data"] = $data;
|
|
return $response;
|
|
}
|
|
|
|
public static function ImATeaPot($data = []) {
|
|
$response = [];
|
|
$response['code'] = 418;
|
|
$response['status'] = "I'm a teapot";
|
|
$response["data"] = $data;
|
|
return $response;
|
|
}
|
|
|
|
|
|
} |