From ae0479337749ef1ca60b3de25e70a7b90b2a1bc9 Mon Sep 17 00:00:00 2001 From: Markus Podar Date: Sun, 17 Mar 2024 14:22:48 +0100 Subject: [PATCH] Allow carbon ^3 Adjust getMinutesUntilExpired() to be compatible with existing behavior. Before carbon^3, the result was a rounded integer. With carbon^3, the result was: - negative (-2....) - a decimal (.9....) Rounding and adding the second `true` parameter keeps in BC. --- composer.json | 2 +- src/Blacklist.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ca0dc110..3e07720b 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "illuminate/support": "^6|^7|^8.67|^9|^10|^11", "lcobucci/jwt": "^4.0", "namshi/jose": "^7.0", - "nesbot/carbon": "^2.0" + "nesbot/carbon": "^2.0|^3.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Blacklist.php b/src/Blacklist.php index 07e79ef9..746c96d8 100644 --- a/src/Blacklist.php +++ b/src/Blacklist.php @@ -95,7 +95,7 @@ protected function getMinutesUntilExpired(Payload $payload) // get the latter of the two expiration dates and find // the number of minutes until the expiration date, // plus 1 minute to avoid overlap - return $exp->max($iat->addMinutes($this->refreshTTL))->addMinute()->diffInRealMinutes(); + return round($exp->max($iat->addMinutes($this->refreshTTL))->addMinute()->diffInRealMinutes(null, true)); } /**