Skip to content

Commit

Permalink
Merge pull request #93 from Shoperti/drop-support-php54-php55
Browse files Browse the repository at this point in the history
[3.0] Drop support for php54 and php56
  • Loading branch information
joecohens authored Oct 3, 2017
2 parents d70d8fb + cc21fc6 commit 5fc8ffb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
language: php

php:
- 5.4
- 5.5
- 5.5.9
- 5.6
- 7.0
- 7.1

sudo: false

install:
- travis_retry composer install --no-interaction --prefer-source

script:
- if [ "$TRAVIS_PHP_VERSION" != "5.5.9" ] && [ "$TRAVIS_PHP_VERSION" != "5.5" ] && [ "$TRAVIS_PHP_VERSION" != "5.6" ]; then vendor/bin/phpunit; fi
- if [ "$TRAVIS_PHP_VERSION" == "5.5.9" ] || [ "$TRAVIS_PHP_VERSION" == "5.5" ] || [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi
- if [ "$TRAVIS_PHP_VERSION" != "5.6" ] && [ "$TRAVIS_PHP_VERSION" != "7.0" ]; then vendor/bin/phpunit; fi
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ] || [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi

after_script:
- if [ "$TRAVIS_PHP_VERSION" == "5.5.9" ] || [ "$TRAVIS_PHP_VERSION" == "5.5" ] || [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [ "$TRAVIS_PHP_VERSION" == "5.5.9" ] || [ "$TRAVIS_PHP_VERSION" == "5.5" ] || [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ] || [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ] || [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
}
],
"require": {
"php": ">=5.4.0",
"guzzlehttp/guzzle": "~5.3|~6.0"
"php": ">=5.6.0",
"guzzlehttp/guzzle": "~6.0"
},
"require-dev": {
"phpunit/phpunit": "^4.1"
Expand Down
16 changes: 15 additions & 1 deletion src/Gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
namespace Shoperti\PayMe\Gateways;

use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\TransferException;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use InvalidArgumentException;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Shoperti\PayMe\Contracts\GatewayInterface;
use Shoperti\PayMe\Currency;

Expand Down Expand Up @@ -71,7 +77,15 @@ public function setConfig($config)
*/
protected function getHttpClient()
{
return new GuzzleClient();
$stack = HandlerStack::create();

$stack->push(Middleware::retry(function ($retries, RequestInterface $request, ResponseInterface $response = null, TransferException $exception = null) {
return $retries < 3 && ($exception instanceof ConnectException || ($response && $response->getStatusCode() >= 500));
}, function ($retries) {
return (int) pow(2, $retries) * 1000;
}));

return new GuzzleClient(['handler' => $stack]);
}

/**
Expand Down

0 comments on commit 5fc8ffb

Please sign in to comment.