Skip to content

Commit

Permalink
Cater for both Carbon v2 and v3 - issue #260
Browse files Browse the repository at this point in the history
  • Loading branch information
specialtactics committed Jul 23, 2024
1 parent 7e91edf commit 83653d5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Blacklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ 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 round($exp->max($iat->addMinutes($this->refreshTTL))->addMinute()->diffInRealMinutes(null, true));
$intermediateResult = $exp->max($iat->addMinutes($this->refreshTTL))->addMinute();

// Handle Carbon 2 vs 3 deprecation of "Real" diff functions, see https://github.com/PHP-Open-Source-Saver/jwt-auth/issues/260
if (method_exists($intermediateResult, 'diffInRealMinutes')) {
return round($intermediateResult->diffInRealMinutes(null, true));
} else {
return (int) round($intermediateResult->diffInMinutes(null, true));
}
}

/**
Expand Down

0 comments on commit 83653d5

Please sign in to comment.