Skip to content

Commit

Permalink
Add support for laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLevti committed Dec 27, 2024
1 parent e4eecfa commit 1bfcb92
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@
"minimum-stability": "stable",
"prefer-stable": true,
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.17.0",
"illuminate/cache": "^9.38.0 || ^10.13.2 || ^11.36.1",
"phpstan/phpstan": "^1.10.16",
"phpunit/phpunit": "^9.5.26 || ^10.2.1",
"friendsofphp/php-cs-fixer": "^3.25.1",
"illuminate/cache": "^9.38.0 || ^10.21.0 || ^11.36.1",
"phpstan/phpstan": "^1.10.32",
"phpunit/phpunit": "^9.5.26 || ^10.3.2",
"roave/security-advisories": "dev-latest"
},
"require": {
"php": "^8.1.0",
"guzzlehttp/guzzle": "^6.5.8 || ^7.4.5",
"guzzlehttp/promises": "^1.0.0",
"guzzlehttp/promises": "^1.4.0 || ^2.0.0",
"nesbot/carbon": "^3.0.0",
"psr/http-message": "^1.0.0 || ^2.0.0",
"psr/simple-cache": "^1.0.0 || ^2.0.0 || ^3.0.0"
Expand Down
28 changes: 16 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions src/RetryAfterMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Promise\Create;
use GuzzleHttp\Promise\PromiseInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\SimpleCache\CacheInterface;
use Throwable;

use function GuzzleHttp\Promise\rejection_for;

class RetryAfterMiddleware
{
public const HEADER = 'Retry-After';
Expand Down Expand Up @@ -49,7 +48,7 @@ public function __invoke(callable $handler): callable

$now = new CarbonImmutable();
if ($retryAfter->greaterThanOrEqualTo($now)) {
return rejection_for(new RetryAfterException(
return Create::rejectionFor(new RetryAfterException(
$this->retryAfterMessage($retryAfter, $now),
$request,
));
Expand All @@ -67,7 +66,7 @@ function (Throwable $reason) use ($key): PromiseInterface {
$this->checkHeader($reason->getResponse(), $key);
}

return rejection_for($reason);
return Create::rejectionFor($reason);
}
);
};
Expand Down
4 changes: 2 additions & 2 deletions tests/RetryAfterMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function it_fails_during_retry_after_date_period($mockHttpHandler): void

$cachedRetryAfterObj = new CarbonImmutable($cachedRetryAfter);

$this->assertSame(self::RETRY_AFTER_SECONDS, $now->diffInSeconds($cachedRetryAfterObj));
$this->assertSame(self::RETRY_AFTER_SECONDS, (int)$now->diffInSeconds($cachedRetryAfterObj));

// Second request is stopped at the beginning of retry after period
try {
Expand Down Expand Up @@ -202,7 +202,7 @@ public function it_fails_during_retry_after_seconds_period($mockHttpHandler): vo

$cachedRetryAfterObj = new CarbonImmutable($cachedRetryAfter);

$this->assertSame(self::RETRY_AFTER_SECONDS, $now->diffInSeconds($cachedRetryAfterObj));
$this->assertSame(self::RETRY_AFTER_SECONDS, (int)$now->diffInSeconds($cachedRetryAfterObj));

// Second request is stopped at the beginning of retry after period
try {
Expand Down

0 comments on commit 1bfcb92

Please sign in to comment.