File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ class AccessToken extends BaseClient
49
49
*/
50
50
public function __construct (array $ config = [], CacheInterface $ cache = null )
51
51
{
52
- parent ::__construct ();
52
+ parent ::__construct ($ config );
53
53
$ this ->accessKey = $ config ['access_key ' ] ?? '' ;
54
54
$ this ->secretKey = $ config ['secret_key ' ] ?? '' ;
55
55
$ this ->limit = $ config ['limit ' ] ?? 20 ;
Original file line number Diff line number Diff line change @@ -43,12 +43,20 @@ class BaseClient
43
43
*/
44
44
protected $ baseUri ;
45
45
46
+ /**
47
+ * @var int
48
+ */
49
+ protected $ timeout = 10 ;
50
+
46
51
/**
47
52
* BaseClient constructor.
48
53
*/
49
- public function __construct ()
54
+ public function __construct (array $ config = [] )
50
55
{
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 ]);
52
60
$ this ->initConfig ();
53
61
}
54
62
@@ -62,6 +70,16 @@ public function initConfig()
62
70
$ this ->config = (new Config ())->toArray ();
63
71
}
64
72
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
+
65
83
/**
66
84
* 设置基础配置
67
85
* @param array $config
You can’t perform that action at this time.
0 commit comments