| 1 | <?php |
||
| 6 | class Limiter |
||
| 7 | { |
||
| 8 | protected StoreInterface $store; |
||
|
|
|||
| 9 | |||
| 10 | public function __construct(StoreInterface $store) |
||
| 11 | 9 | { |
|
| 12 | $this->store = $store; |
||
| 13 | 9 | } |
|
| 14 | 9 | ||
| 15 | public function get(string $key): int |
||
| 16 | 5 | { |
|
| 17 | return $this->store->get($key); |
||
| 18 | 5 | } |
|
| 19 | |||
| 20 | public function inc(string $key, int $ttl = 60): int |
||
| 21 | 8 | { |
|
| 22 | return $this->store->inc($key, $ttl); |
||
| 23 | 8 | } |
|
| 24 | |||
| 25 | public function reset(string $key): bool |
||
| 26 | 5 | { |
|
| 27 | return $this->store->reset($key); |
||
| 28 | 5 | } |
|
| 29 | |||
| 30 | public function isExceeded(string $key, int $max): bool |
||
| 31 | 5 | { |
|
| 32 | return $this->store->isExceeded($key, $max); |
||
| 33 | 5 | } |
|
| 34 | |||
| 35 | public function ttl(string $key): ?int |
||
| 36 | 1 | { |
|
| 37 | return $this->store->ttl($key); |
||
| 38 | 1 | } |
|
| 39 | } |
||
| 40 |