| Total Complexity | 5 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | final class CounterStatistics |
||
| 11 | { |
||
| 12 | private int $limit; |
||
| 13 | private int $remaining; |
||
| 14 | private int $reset; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @param int $limit the maximum number of requests allowed with a time period |
||
| 18 | * @param int $remaining the number of remaining requests in the current time period |
||
| 19 | * @param int $reset timestamp to wait until the rate limit resets |
||
| 20 | */ |
||
| 21 | public function __construct(int $limit, int $remaining, int $reset) |
||
| 22 | { |
||
| 23 | $this->limit = $limit; |
||
| 24 | $this->remaining = $remaining; |
||
| 25 | $this->reset = $reset; |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @return int the maximum number of requests allowed with a time period |
||
| 30 | */ |
||
| 31 | public function getLimit(): int |
||
| 32 | { |
||
| 33 | return $this->limit; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @return int the number of remaining requests in the current time period |
||
| 38 | */ |
||
| 39 | public function getRemaining(): int |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return int timestamp to wait until the rate limit resets |
||
| 46 | */ |
||
| 47 | public function getResetTime(): int |
||
| 48 | { |
||
| 49 | return $this->reset; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return bool if requests limit is reached |
||
| 54 | */ |
||
| 55 | public function isLimitReached(): bool |
||
| 58 | } |
||
| 59 | } |
||
| 60 |