Skip to content

Commit c408b96

Browse files
author
Tim Helfensdörfer
committed
Added configurable timeout
1 parent a296e8b commit c408b96

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/Matomo.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ class Matomo
9797
*/
9898
private $_maxRedirects = 5;
9999

100+
/**
101+
* @var int Timeout in seconds.
102+
*/
103+
private $_timeout = 5;
104+
100105
/**
101106
* Create a new instance.
102107
*
@@ -447,6 +452,24 @@ public function setMaxRedirects(int $maxRedirects): Matomo
447452
return $this;
448453
}
449454

455+
/**
456+
* @return int
457+
*/
458+
public function getTimeout(): int
459+
{
460+
return $this->_timeout;
461+
}
462+
463+
/**
464+
* @param int $timeout
465+
*/
466+
public function setTimeout(int $timeout): Matomo
467+
{
468+
$this->_timeout = $timeout;
469+
470+
return $this;
471+
}
472+
450473
/**
451474
* Reset all default variables.
452475
*/
@@ -487,7 +510,7 @@ private function _request(string $method, array $params = [], array $optional =
487510
$req->disableStrictSSL();
488511
}
489512
$req->followRedirects($this->_maxRedirects);
490-
$req->withTimeout(5);
513+
$req->withTimeout($this->_timeout);
491514

492515
try {
493516
$buffer = $req->send();

0 commit comments

Comments
 (0)