This commit is contained in:
2021-09-30 17:06:57 +08:00
parent 3fc18c71a2
commit eaa1916cad
2 changed files with 9 additions and 22 deletions
+9 -8
View File
@@ -8,7 +8,6 @@ use Closure;
use Http\Handler\Context;
use Http\Message\Stream;
use JetBrains\PhpStorm\Pure;
use Kiri\Abstracts\Component;
use Kiri\Core\Help;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
@@ -21,7 +20,7 @@ defined('SPLIT_URL') or define('SPLIT_URL', '/(http[s]?:\/\/)?(([\w\-_]+\.)+\w+(
* Class ClientAbstracts
* @package Http\Handler\Client
*/
abstract class ClientAbstracts extends Component implements IClient
abstract class ClientAbstracts implements IClient
{
const POST = 'post';
@@ -55,11 +54,13 @@ abstract class ClientAbstracts extends Component implements IClient
/**
* @return static
* @param $host
* @param $port
* @param false $isSSL
*/
public static function NewRequest(): static
public function __construct($host, $port, bool $isSSL = false)
{
return new static();
$this->withHost($host)->withPort($port)->withIsSSL($isSSL);
}
@@ -185,7 +186,7 @@ abstract class ClientAbstracts extends Component implements IClient
* @param string $host
* @return ClientAbstracts
*/
public function withHost(string $host): static
private function withHost(string $host): static
{
$this->host = $host;
if (Context::inCoroutine()) {
@@ -297,7 +298,7 @@ abstract class ClientAbstracts extends Component implements IClient
* @param bool $isSSL
* @return ClientAbstracts
*/
public function withIsSSL(bool $isSSL): static
private function withIsSSL(bool $isSSL): static
{
$this->isSSL = $isSSL;
return $this;
@@ -394,7 +395,7 @@ abstract class ClientAbstracts extends Component implements IClient
* @param int $port
* @return ClientAbstracts
*/
public function withPort(int $port): static
private function withPort(int $port): static
{
$this->port = $port;
return $this;
-14
View File
@@ -77,13 +77,6 @@ interface IClient
public function request(string $method, string $path, array $params = []): ResponseInterface;
/**
* @param string $host
* @return static
*/
public function withHost(string $host): static;
/**
* @param array $header
* @return static
@@ -162,13 +155,6 @@ interface IClient
public function withCa(string $ssl_key_file): static;
/**
* @param int $port
* @return static
*/
public function withPort(int $port): static;
/**
* @param string|StreamInterface $data
* @return static