优化是否鉴权
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled

This commit is contained in:
2025-12-01 10:56:30 +08:00
parent 120a88da30
commit 527373853e
2 changed files with 11 additions and 14 deletions

View File

@@ -7,25 +7,22 @@ use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
class BaseClient class BaseClient extends BaseService
{ {
private static mixed $_instance;
/** protected $client;
* 获取实例
* @return null|static protected string $baseUrl = '';
*/ protected array $headers = [];
public static function getInstance(): null|static
public function __construct()
{ {
$name = get_called_class(); $this->isAuth = false;
if (!isset(self::$_instance[$name])) { parent::__construct();
self::$_instance[$name] = new static();
}
return self::$_instance[$name];
} }
/** /**
* 初始化请求类 * 初始化请求类
* @return $this * @return $this

View File

@@ -92,7 +92,7 @@ class BaseService
/** /**
* @var bool 是否鉴权 * @var bool 是否鉴权
*/ */
private $isAuth = true; protected $isAuth = true;
public function __construct() public function __construct()
{ {