From eaa1916cade8785f0a44aff78c7427f1719c928d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 30 Sep 2021 17:06:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ClientAbstracts.php | 17 +++++++++-------- src/IClient.php | 14 -------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/ClientAbstracts.php b/src/ClientAbstracts.php index 12f20b6..f33feab 100644 --- a/src/ClientAbstracts.php +++ b/src/ClientAbstracts.php @@ -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; diff --git a/src/IClient.php b/src/IClient.php index 9ace49c..9ab1349 100644 --- a/src/IClient.php +++ b/src/IClient.php @@ -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