PHD Project - Driver energy prediction
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

31 lines
698 B

<?php
// This is highly incomplete
class HttpResponse {
private $code;
private $msg;
private function __construct(int $code, string $msg) {
$this->code = $code;
$this->msg = $msg;
}
public function set_and_exit() {
http_response_code($this->code);
echo $this->msg;
exit;
}
public static function bad_request() {
return new HttpResponse(400, 'Bad Request');
}
public static function forbidden() {
return new HttpResponse(403, 'Forbidden');
}
public static function not_found() {
return new HttpResponse(404, 'Not Found');
}
public static function internal_server_error() {
return new HttpResponse(500, 'Internal Server Error');
}
}