This commit is contained in:
2021-09-09 19:23:21 +08:00
parent e53b060022
commit 9915452311
2 changed files with 209 additions and 0 deletions
+127
View File
@@ -0,0 +1,127 @@
<?php
namespace Server\Constrict;
use Psr\Http\Message\ServerRequestInterface;
/**
*
*/
class ServerRequest extends TRequest implements ServerRequestInterface
{
/**
* @return array
*/
public function getServerParams(): array
{
return [];
}
/**
* @return array
*/
public function getCookieParams(): array
{
return $this->cookies;
}
/**
* @param array $cookies
* @return $this|ServerRequest
*/
public function withCookieParams(array $cookies): ServerRequestInterface
{
$this->cookies = $cookies;
return $this;
}
/**
* @return array
*/
public function getQueryParams(): array
{
return [];
}
public function withQueryParams(array $query): ServerRequestInterface
{
return $this;
}
public function getUploadedFiles()
{
// TODO: Implement getUploadedFiles() method.
}
public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface
{
return $this;
}
/**
* @return array|object|null
*/
public function getParsedBody(): object|array|null
{
return null;
}
/**
* @param array|object|null $data
* @return ServerRequestInterface
*/
public function withParsedBody($data): ServerRequestInterface
{
return $this;
}
/**
* @return array
*/
public function getAttributes(): array
{
return [];
}
/**
* @param string $name
* @param null $default
* @return mixed|null
*/
public function getAttribute($name, $default = null)
{
return $default;
}
/**
* @param string $name
* @param mixed $value
* @return ServerRequestInterface
*/
public function withAttribute($name, $value): ServerRequestInterface
{
return $this;
}
/**
* @param string $name
* @return ServerRequestInterface
*/
public function withoutAttribute($name): ServerRequestInterface
{
// TODO: Implement withoutAttribute() method.
return $this;
}
}
+82
View File
@@ -0,0 +1,82 @@
<?php
namespace Server\Constrict;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\UriInterface;
use Server\Message\Message;
class TRequest implements RequestInterface
{
use Message;
private UriInterface $uri;
private string $method;
/**
* @return string
*/
public function getRequestTarget(): string
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @param mixed $requestTarget
* @return static
*/
public function withRequestTarget($requestTarget): static
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @return string
*/
public function getMethod(): string
{
// TODO: Implement getMethod() method.
return $this->method;
}
/**
* @param string $method
* @return RequestInterface
*/
public function withMethod($method): RequestInterface
{
// TODO: Implement withMethod() method.
$this->method = $method;
return $this;
}
/**
* @return UriInterface
*/
public function getUri(): UriInterface
{
// TODO: Implement getUri() method.
return $this->uri;
}
/**
* @param UriInterface $uri
* @param false $preserveHost
* @return $this|TRequest
*/
public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface
{
$this->uri = $uri;
return $this;
}
}