Skip to content

Commit 2217791

Browse files
author
Openset
committed
Add: setConfig
1 parent a39b1f9 commit 2217791

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/HttpClient.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,25 @@ class HttpClient
1616
*/
1717
protected static $client;
1818

19+
protected static $defaults = [
20+
'debug' => false,
21+
'verify' => true,
22+
// You can set any number of default request options.
23+
'timeout' => 30,
24+
];
25+
26+
public static function setConfig(array $config)
27+
{
28+
self::$defaults = $config + self::$defaults;
29+
}
30+
1931
/**
2032
* @return Client
2133
*/
2234
public static function getClient()
2335
{
2436
if (is_null(self::$client)) {
25-
self::$client = new Client([
26-
// You can set any number of default request options.
27-
'timeout' => 30.0,
28-
]);
37+
self::$client = new Client(self::$defaults);
2938
}
3039

3140
return self::$client;

0 commit comments

Comments
 (0)