|
2 | 2 |
|
3 | 3 | use InvalidArgumentException; |
4 | 4 |
|
5 | | -use Httpful\Exception\ConnectionErrorException; |
| 5 | +use Httpful\Exception\NetworkErrorException; |
6 | 6 | use Httpful\Request; |
7 | 7 | use Httpful\Response; |
8 | 8 |
|
@@ -98,11 +98,6 @@ class Matomo |
98 | 98 | */ |
99 | 99 | private $_maxRedirects = 5; |
100 | 100 |
|
101 | | - /** |
102 | | - * @var null|int Maximum number of seconds the request might take |
103 | | - */ |
104 | | - private $_connectionTimeout = 5; |
105 | | - |
106 | 101 | /** |
107 | 102 | * Create a new instance. |
108 | 103 | * |
@@ -453,29 +448,6 @@ public function setMaxRedirects(int $maxRedirects): Matomo |
453 | 448 | return $this; |
454 | 449 | } |
455 | 450 |
|
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 | | - |
479 | 451 | /** |
480 | 452 | * Reset all default variables. |
481 | 453 | */ |
@@ -510,16 +482,17 @@ private function _request(string $method, array $params = [], array $optional = |
510 | 482 | } |
511 | 483 |
|
512 | 484 | $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); |
519 | 492 |
|
520 | 493 | try { |
521 | 494 | $buffer = $req->send(); |
522 | | - } catch (ConnectionErrorException $e) { |
| 495 | + } catch (NetworkErrorException $e) { |
523 | 496 | throw new InvalidRequestException($e->getMessage(), $e->getCode(), $e); |
524 | 497 | } |
525 | 498 |
|
@@ -564,7 +537,7 @@ private function _finishResponse($response, string $method, array $params) |
564 | 537 | * @param string $method The request method |
565 | 538 | * @param array $params Request params |
566 | 539 | * @return string|false |
567 | | - * @throws \InvalidArgumentException |
| 540 | + * @throws InvalidArgumentException |
568 | 541 | */ |
569 | 542 | private function _parseUrl(string $method, array $params = []) |
570 | 543 | { |
|
0 commit comments