Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark authored and StyleCIBot committed Nov 20, 2020
1 parent a59c1bd commit 866554b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Counter.php
Expand Up @@ -109,6 +109,7 @@ public function incrementAndGetState(): CounterState

/**
* @param float $storedTheoreticalNextIncrementTime
*
* @return float theoretical increment time that would be expected from equally spaced increments at exactly rate limit
* In GCRA it is known as TAT, theoretical arrival time.
*/
Expand All @@ -119,6 +120,7 @@ private function calculateTheoreticalNextIncrementTime(float $storedTheoreticalN

/**
* @param float $theoreticalNextIncrementTime
*
* @return int the number of remaining requests in the current time period
*/
private function calculateRemaining(float $theoreticalNextIncrementTime): int
Expand All @@ -140,6 +142,7 @@ private function storeTheoreticalNextIncrementTime(float $theoreticalNextIncreme

/**
* @param float $theoreticalNextIncrementTime
*
* @return int timestamp to wait until the rate limit resets
*/
private function calculateResetAfter(float $theoreticalNextIncrementTime): int
Expand Down
1 change: 1 addition & 0 deletions src/CounterInterface.php
Expand Up @@ -17,6 +17,7 @@ public function setId(string $id): void;

/**
* Counts one request as done and returns object containing current counter state
*
* @return CounterState
*/
public function incrementAndGetState(): CounterState;
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware.php
Expand Up @@ -78,7 +78,7 @@ private function createErrorResponse(): ResponseInterface
private function generateId(ServerRequestInterface $request): string
{
if ($this->counterIdCallback !== null) {
return \call_user_func($this->counterIdCallback, $request);
return ($this->counterIdCallback)($request);
}

return $this->counterId ?? $this->generateIdFromRequest($request);
Expand Down
2 changes: 2 additions & 0 deletions tests/CounterTest.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Yii\RateLimiter\Tests;

use InvalidArgumentException;
Expand Down
2 changes: 2 additions & 0 deletions tests/FakeCounter.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Yii\RateLimiter\Tests;

use Yiisoft\Yii\RateLimiter\CounterInterface;
Expand Down
2 changes: 2 additions & 0 deletions tests/MiddlewareTest.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Yii\RateLimiter\Tests;

use Nyholm\Psr7\Factory\Psr17Factory;
Expand Down

0 comments on commit 866554b

Please sign in to comment.