改名
This commit is contained in:
@@ -5,14 +5,15 @@ namespace Server\Constrict;
|
||||
|
||||
|
||||
use Http\Context\Context;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Server\Message\Response as Psr7Response;
|
||||
use Server\ResponseInterface;
|
||||
use Server\SInterface\DownloadInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class Response
|
||||
* @package Server
|
||||
* @mixin Psr7Response
|
||||
*/
|
||||
class Response implements ResponseInterface
|
||||
{
|
||||
@@ -22,15 +23,6 @@ class Response implements ResponseInterface
|
||||
const HTML = 'html';
|
||||
const FILE = 'file';
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $args
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($name, $args)
|
||||
{
|
||||
return $this->__call__()->{$name}(...$args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
@@ -49,4 +41,242 @@ class Response implements ResponseInterface
|
||||
{
|
||||
return Context::getContext(ResponseInterface::class, new Psr7Response());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProtocolVersion(): string
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $version
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function withProtocolVersion($version): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($version);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders(): array
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function hasHeader($name): bool
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function getHeader($name): string
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function getHeaderLine($name): string
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string|string[] $value
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function withHeader($name, $value): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($name, $value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string|string[] $value
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function withAddedHeader($name, $value): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($name, $value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function withoutHeader($name): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return StreamInterface
|
||||
*/
|
||||
public function getBody(): StreamInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param StreamInterface $body
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function withBody(StreamInterface $body): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $code
|
||||
* @param string $reasonPhrase
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function withStatus($code, $reasonPhrase = ''): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($code, $reasonPhrase);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReasonPhrase(): string
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return DownloadInterface
|
||||
*/
|
||||
public function file(string $path): DownloadInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $responseData
|
||||
* @return string|array|bool|int|null
|
||||
*/
|
||||
public function _toArray($responseData): string|array|null|bool|int
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($responseData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function xml($data): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function html($data): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function json($data): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContentType(): string
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasContentType(): bool
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function withContentType(string $type): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($type);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function withAccessControlAllowOrigin(string $data): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function withAccessControlRequestMethod(string $data): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function withAccessControlAllowHeaders(string $data): ResponseInterface
|
||||
{
|
||||
return $this->__call__()->{__METHOD__}($data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user