33 lines
641 B
PHP
33 lines
641 B
PHP
<?php
|
|
|
|
namespace lib\Http;
|
|
|
|
class Response extends HTTP
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public static function json($data, int $status = 200)
|
|
{
|
|
http_response_code($status);
|
|
header('Content-Type: application/json');
|
|
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
public static function view(string $html, int $status = 200)
|
|
{
|
|
http_response_code(200);
|
|
header('Content-Type: text/html');
|
|
echo $html;
|
|
}
|
|
|
|
public static function text(string $text, int $status = 200)
|
|
{
|
|
http_response_code($status);
|
|
header('Content-Type: text/plain');
|
|
echo $text;
|
|
}
|
|
}
|