| Total Complexity | 5 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | final class CounterState |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @param int $limit The maximum number of requests allowed with a time period. |
||
| 14 | * @param int $remaining The number of remaining requests in the current time period. |
||
| 15 | * @param int $resetTime Timestamp to wait until the rate limit resets. |
||
| 16 | */ |
||
| 17 | 9 | public function __construct(private int $limit, private int $remaining, private int $resetTime) |
|
| 18 | { |
||
| 19 | 9 | } |
|
| 20 | |||
| 21 | /** |
||
| 22 | * @return int The maximum number of requests allowed with a time period. |
||
| 23 | */ |
||
| 24 | 7 | public function getLimit(): int |
|
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @return int The number of remaining requests in the current time period. |
||
| 31 | */ |
||
| 32 | 8 | public function getRemaining(): int |
|
| 33 | { |
||
| 34 | 8 | return $this->remaining; |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @return int Timestamp to wait until the rate limit resets. |
||
| 39 | */ |
||
| 40 | 7 | public function getResetTime(): int |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @return bool If requests limit is reached. |
||
| 47 | */ |
||
| 48 | 7 | public function isLimitReached(): bool |
|
| 51 | } |
||
| 52 | } |
||
| 53 |