This commit is contained in:
2022-01-09 13:54:34 +08:00
parent 1db430f997
commit f838795983
10 changed files with 1710 additions and 1710 deletions
+43 -43
View File
@@ -1,43 +1,43 @@
<?php
namespace Http\Client;
use Kiri\Context;
/**
* @mixin CoroutineClient|CurlClient
*/
class Client
{
private CoroutineClient|CurlClient|AsyncClient $abstracts;
/**
* @param string $host
* @param int $port
* @param bool $isSsl
*/
public function __construct(string $host, int $port, bool $isSsl = false)
{
if (Context::inCoroutine()) {
$this->abstracts = new CoroutineClient($host, $port, $isSsl);
} else {
$this->abstracts = new CurlClient($host, $port, $isSsl);
}
}
/**
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call(string $name, array $arguments)
{
return $this->abstracts->{$name}(...$arguments);
}
}
<?php
namespace Http\Client;
use Kiri\Context;
/**
* @mixin CoroutineClient|CurlClient
*/
class Client
{
private CoroutineClient|CurlClient|AsyncClient $abstracts;
/**
* @param string $host
* @param int $port
* @param bool $isSsl
*/
public function __construct(string $host, int $port, bool $isSsl = false)
{
if (Context::inCoroutine()) {
$this->abstracts = new CoroutineClient($host, $port, $isSsl);
} else {
$this->abstracts = new CurlClient($host, $port, $isSsl);
}
}
/**
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call(string $name, array $arguments)
{
return $this->abstracts->{$name}(...$arguments);
}
}