Merge pull request #3271 from michalsn/throttler_code_style

Throttler code style update
This commit is contained in:
Michal Sniatala 2020-07-11 16:05:03 +02:00 committed by GitHub
commit 0ac618c37f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -139,7 +139,8 @@ class Throttler implements ThrottlerInterface
$tokenName = $this->prefix . $key;
// Check to see if the bucket has even been created yet.
if (($tokens = $this->cache->get($tokenName)) === null) {
if (($tokens = $this->cache->get($tokenName)) === null)
{
// If it hasn't been created, then we'll set it to the maximum
// capacity - 1, and save it to the cache.
$this->cache->save($tokenName, $capacity - $cost, $seconds);
@ -170,7 +171,8 @@ class Throttler implements ThrottlerInterface
// If $tokens >= 1, then we are safe to perform the action, but
// we need to decrement the number of available tokens.
if ($tokens >= 1) {
if ($tokens >= 1)
{
$this->cache->save($tokenName, $tokens - $cost, $seconds);
$this->cache->save($tokenName . 'Time', time(), $seconds);