Files
kiri-core/http-message/Request.php
T

116 lines
2.0 KiB
PHP
Raw Normal View History

2021-09-09 19:23:21 +08:00
<?php
2021-09-10 03:33:45 +08:00
namespace Protocol\Message;
2021-09-09 19:23:21 +08:00
2021-09-10 03:33:45 +08:00
use BadMethodCallException;
2021-09-10 03:54:16 +08:00
use Http\IInterface\AuthIdentity;
2021-09-09 19:23:21 +08:00
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\UriInterface;
2021-09-10 03:33:45 +08:00
/**
*
*/
abstract class Request implements RequestInterface
2021-09-09 19:23:21 +08:00
{
2021-09-10 03:50:45 +08:00
use Message;
2021-09-09 19:23:21 +08:00
2021-09-10 03:33:45 +08:00
/**
* @var \Psr\Http\Message\UriInterface
*/
protected UriInterface $uriInterface;
2021-09-09 19:23:21 +08:00
2021-09-10 03:33:45 +08:00
/**
* @var string
*/
protected string $method;
2021-09-09 19:23:21 +08:00
2021-09-10 03:54:16 +08:00
/**
* @var \Http\IInterface\AuthIdentity
*/
public AuthIdentity $authority;
/**
* @param \Http\IInterface\AuthIdentity $authIdentity
*/
public function setAuthority(AuthIdentity $authIdentity): void
{
$this->authority = $authIdentity;
}
2021-09-10 03:50:45 +08:00
/**
* @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.');
}
2021-09-09 19:23:21 +08:00
2021-09-10 03:50:45 +08:00
/**
* @return string
*/
public function getMethod(): string
{
return $this->method;
}
/**
* @param string $method
* @return RequestInterface
*/
public function withMethod($method): RequestInterface
{
$this->method = $method;
return $this;
}
/**
* @param string $method
* @return bool
*/
public function isMethod(string $method): bool
{
return $this->method == $method;
}
/**
* @return UriInterface
*/
public function getUri(): UriInterface
{
return $this->uriInterface;
}
/**
* @param UriInterface $uri
* @param false $preserveHost
* @return $this|Request
*/
public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface
{
$this->uriInterface = $uri;
return $this;
}
2021-09-09 19:23:21 +08:00
}