Skip to content

Commit ba7f05a

Browse files
author
Tim Helfensdörfer
committed
Merge
1 parent 30aa306 commit ba7f05a

File tree

3 files changed

+14
-39
lines changed

3 files changed

+14
-39
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### 1.5.1 (2019/07/22)
44

55
* Changed: Moved changelog to separate file
6+
* Changed: Updated dependencies
67

78
### 1.5.0 (2019/04/11)
89

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
"require": {
66
"php": ">=7.2",
77
"ext-json": "*",
8-
"voku/httpful": "0.4.*"
8+
"ext-curl": "*",
9+
"voku/httpful": "0.9.*"
910
},
1011
"require-dev": {
11-
"phpunit/phpunit": "8.1.*"
12+
"phpunit/phpunit": "8.2.*"
1213
},
1314
"autoload": {
1415
"psr-4": {

src/Matomo.php

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use InvalidArgumentException;
44

5-
use Httpful\Exception\ConnectionErrorException;
5+
use Httpful\Exception\NetworkErrorException;
66
use Httpful\Request;
77
use Httpful\Response;
88

@@ -98,11 +98,6 @@ class Matomo
9898
*/
9999
private $_maxRedirects = 5;
100100

101-
/**
102-
* @var null|int Maximum number of seconds the request might take
103-
*/
104-
private $_connectionTimeout = 5;
105-
106101
/**
107102
* Create a new instance.
108103
*
@@ -453,29 +448,6 @@ public function setMaxRedirects(int $maxRedirects): Matomo
453448
return $this;
454449
}
455450

456-
/**
457-
* How many seconds until the request errors.
458-
*
459-
* @return null|int
460-
*/
461-
public function getConnectionTimeout(): ?int
462-
{
463-
return $this->_connectionTimeout;
464-
}
465-
466-
/**
467-
* Set how many seconds until the request errors.
468-
*
469-
* @param null|int $connectionTimeout
470-
* @return Matomo
471-
*/
472-
public function setConnectionTimeout(?int $connectionTimeout = null): Matomo
473-
{
474-
$this->_connectionTimeout = $connectionTimeout;
475-
476-
return $this;
477-
}
478-
479451
/**
480452
* Reset all default variables.
481453
*/
@@ -510,16 +482,17 @@ private function _request(string $method, array $params = [], array $optional =
510482
}
511483

512484
$req = Request::get($url);
513-
$req->strict_ssl = $this->_verifySsl;
514-
$req->max_redirects = $this->_maxRedirects;
515-
516-
if (is_int($this->getConnectionTimeout())) {
517-
$req->setConnectionTimeout($this->getConnectionTimeout());
518-
}
485+
if ($this->_verifySsl) {
486+
$req->enableStrictSSL();
487+
} else {
488+
$req->disableStrictSSL();
489+
}
490+
$req->followRedirects($this->_maxRedirects);
491+
$req->withTimeout(5);
519492

520493
try {
521494
$buffer = $req->send();
522-
} catch (ConnectionErrorException $e) {
495+
} catch (NetworkErrorException $e) {
523496
throw new InvalidRequestException($e->getMessage(), $e->getCode(), $e);
524497
}
525498

@@ -564,7 +537,7 @@ private function _finishResponse($response, string $method, array $params)
564537
* @param string $method The request method
565538
* @param array $params Request params
566539
* @return string|false
567-
* @throws \InvalidArgumentException
540+
* @throws InvalidArgumentException
568541
*/
569542
private function _parseUrl(string $method, array $params = [])
570543
{

0 commit comments

Comments
 (0)