This commit is contained in:
2023-04-16 15:57:50 +08:00
parent 2c3eed0b7a
commit cbcf457e7b
4 changed files with 129 additions and 5 deletions
+56
View File
@@ -28,6 +28,62 @@ class Response implements ResponseInterface
}
/**
* @param array $content
* @param int $statusCode
* @return ResponseInterface
*/
public function json(array $content, int $statusCode = 200): ResponseInterface
{
return $this->__call__(__FUNCTION__, $content, $statusCode);
}
/**
* @param array $content
* @param int $statusCode
* @return ResponseInterface
*/
public function xml(array $content, int $statusCode = 200): ResponseInterface
{
return $this->__call__(__FUNCTION__, $content, $statusCode);
}
/**
* @param string $content
* @param int $statusCode
* @return ResponseInterface
*/
public function html(string $content, int $statusCode = 200): ResponseInterface
{
return $this->__call__(__FUNCTION__, $content, $statusCode);
}
/**
* @param string $content
* @param int $statusCode
* @return ResponseInterface
*/
public function sendfile(string $content, int $statusCode = 200): ResponseInterface
{
return $this->__call__(__FUNCTION__, $content, $statusCode);
}
/**
* @param mixed $data
* @param int $statusCode
* @param ContentType $type
* @return Response
*/
public function write(mixed $data, int $statusCode = 200, ContentType $type = ContentType::JSON): static
{
return $this->__call__(__FUNCTION__, $data, $statusCode, $type);
}
/**
* @param string $method
* @param mixed ...$params