diff --git a/CHANGELOG.md b/CHANGELOG.md index 761aa7e..65e7f72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### 1.5.1 (2019/07/22) * Changed: Moved changelog to separate file +* Changed: Updated dependencies ### 1.5.0 (2019/04/11) diff --git a/composer.json b/composer.json index d09a6b2..986c189 100644 --- a/composer.json +++ b/composer.json @@ -5,10 +5,11 @@ "require": { "php": ">=7.2", "ext-json": "*", - "voku/httpful": "0.4.*" + "ext-curl": "*", + "voku/httpful": "0.9.*" }, "require-dev": { - "phpunit/phpunit": "8.1.*" + "phpunit/phpunit": "8.2.*" }, "autoload": { "psr-4": { diff --git a/src/Matomo.php b/src/Matomo.php index 761ad4f..d509443 100644 --- a/src/Matomo.php +++ b/src/Matomo.php @@ -2,7 +2,7 @@ use InvalidArgumentException; -use Httpful\Exception\ConnectionErrorException; +use Httpful\Exception\NetworkErrorException; use Httpful\Request; use Httpful\Response; @@ -98,11 +98,6 @@ class Matomo */ private $_maxRedirects = 5; - /** - * @var null|int Maximum number of seconds the request might take - */ - private $_connectionTimeout = 5; - /** * Create a new instance. * @@ -453,29 +448,6 @@ public function setMaxRedirects(int $maxRedirects): Matomo return $this; } - /** - * How many seconds until the request errors. - * - * @return null|int - */ - public function getConnectionTimeout(): ?int - { - return $this->_connectionTimeout; - } - - /** - * Set how many seconds until the request errors. - * - * @param null|int $connectionTimeout - * @return Matomo - */ - public function setConnectionTimeout(?int $connectionTimeout = null): Matomo - { - $this->_connectionTimeout = $connectionTimeout; - - return $this; - } - /** * Reset all default variables. */ @@ -510,16 +482,17 @@ private function _request(string $method, array $params = [], array $optional = } $req = Request::get($url); - $req->strict_ssl = $this->_verifySsl; - $req->max_redirects = $this->_maxRedirects; - - if (is_int($this->getConnectionTimeout())) { - $req->setConnectionTimeout($this->getConnectionTimeout()); - } + if ($this->_verifySsl) { + $req->enableStrictSSL(); + } else { + $req->disableStrictSSL(); + } + $req->followRedirects($this->_maxRedirects); + $req->withTimeout(5); try { $buffer = $req->send(); - } catch (ConnectionErrorException $e) { + } catch (NetworkErrorException $e) { throw new InvalidRequestException($e->getMessage(), $e->getCode(), $e); } @@ -564,7 +537,7 @@ private function _finishResponse($response, string $method, array $params) * @param string $method The request method * @param array $params Request params * @return string|false - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ private function _parseUrl(string $method, array $params = []) {