Skip to content

Commit 3a76455

Browse files
committed
Set timeouts in construct
Signed-off-by: Stiliyan Ivanov <[email protected]>
1 parent 191439a commit 3a76455

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Client.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ class Client
3333

3434
/**
3535
* Float describing the number of seconds to wait while trying to connect to a server
36+
* @var float
3637
*/
3738
private $connect_timeout = 30;
3839

3940
/**
4041
* Float describing the total timeout of the request in seconds
42+
* @var float
4143
*/
4244
private $timeout = 60;
4345

@@ -225,10 +227,12 @@ public function setOAuthApiRoot($oAuthApiRoot)
225227
* @param string $clientId
226228
* @param string $clientSecret
227229
*/
228-
public function __construct($clientId = '', $clientSecret = '')
230+
public function __construct($clientId = '', $clientSecret = '', ?float $connect_timeout = null, ?float $timeout = null)
229231
{
230232
!empty($clientId) && $this->setClientId($clientId);
231233
!empty($clientSecret) && $this->setClientSecret($clientSecret);
234+
!is_null($connect_timeout) && $this->setConnectTimeout($connect_timeout);
235+
!is_null($timeout) && $this->setTimeout($timeout);
232236
}
233237

234238
/**
@@ -688,7 +692,7 @@ protected function prepareOptions(array $params, $method)
688692
*
689693
* @return self
690694
*/
691-
public function setConnectTimeout($connect_timeout)
695+
public function setConnectTimeout(float $connect_timeout)
692696
{
693697
$this->connect_timeout = $connect_timeout;
694698

@@ -700,7 +704,7 @@ public function setConnectTimeout($connect_timeout)
700704
*
701705
* @return self
702706
*/
703-
public function setTimeout($timeout)
707+
public function setTimeout(float $timeout)
704708
{
705709
$this->timeout = $timeout;
706710

0 commit comments

Comments
 (0)