Skip to content

Commit 5a69a06

Browse files
committed
调整参数
1 parent f6e0686 commit 5a69a06

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/AccessToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class AccessToken extends BaseClient
4949
*/
5050
public function __construct(array $config = [], CacheInterface $cache = null)
5151
{
52-
parent::__construct();
52+
parent::__construct($config);
5353
$this->accessKey = $config['access_key'] ?? '';
5454
$this->secretKey = $config['secret_key'] ?? '';
5555
$this->limit = $config['limit'] ?? 20;

src/BaseClient.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,20 @@ class BaseClient
4343
*/
4444
protected $baseUri;
4545

46+
/**
47+
* @var int
48+
*/
49+
protected $timeout = 10;
50+
4651
/**
4752
* BaseClient constructor.
4853
*/
49-
public function __construct()
54+
public function __construct(array $config = [])
5055
{
51-
$this->client = new Client(['verify' => $this->verify, 'timeout' => 10]);
56+
if (isset($config['timeout'])) {
57+
$this->timeout = $config['timeout'];
58+
}
59+
$this->client = new Client(['verify' => $this->verify, 'timeout' => $this->timeout]);
5260
$this->initConfig();
5361
}
5462

@@ -62,6 +70,16 @@ public function initConfig()
6270
$this->config = (new Config())->toArray();
6371
}
6472

73+
/**
74+
* @param int $timeout
75+
* @return $this
76+
*/
77+
public function setTimeout(int $timeout)
78+
{
79+
$this->timeout = $timeout;
80+
return $this;
81+
}
82+
6583
/**
6684
* 设置基础配置
6785
* @param array $config

0 commit comments

Comments
 (0)