| @@ 37-53 (lines=17) @@ | ||
| 34 | $this->updateCounter($key, $rate->getInterval()); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function limitSilently(string $identifier, Rate $rate): Status |
|
| 38 | { |
|
| 39 | $key = $this->key($identifier, $rate->getInterval()); |
|
| 40 | ||
| 41 | $current = $this->getCurrent($key); |
|
| 42 | ||
| 43 | if ($current <= $rate->getOperations()) { |
|
| 44 | $current = $this->updateCounter($key, $rate->getInterval()); |
|
| 45 | } |
|
| 46 | ||
| 47 | return Status::from( |
|
| 48 | $identifier, |
|
| 49 | $current, |
|
| 50 | $rate->getOperations(), |
|
| 51 | time() + $this->ttl($key) |
|
| 52 | ); |
|
| 53 | } |
|
| 54 | ||
| 55 | private function key(string $identifier, int $interval): string |
|
| 56 | { |
|
| @@ 37-53 (lines=17) @@ | ||
| 34 | $this->updateCounter($key, $rate->getInterval()); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function limitSilently(string $identifier, Rate $rate): Status |
|
| 38 | { |
|
| 39 | $key = $this->key($identifier, $rate->getInterval()); |
|
| 40 | ||
| 41 | $current = $this->getCurrent($key); |
|
| 42 | ||
| 43 | if ($current <= $rate->getOperations()) { |
|
| 44 | $current = $this->updateCounter($key, $rate->getInterval()); |
|
| 45 | } |
|
| 46 | ||
| 47 | return Status::from( |
|
| 48 | $identifier, |
|
| 49 | $current, |
|
| 50 | $rate->getOperations(), |
|
| 51 | time() + $this->ttl($key) |
|
| 52 | ); |
|
| 53 | } |
|
| 54 | ||
| 55 | private function key(string $identifier, int $interval): string |
|
| 56 | { |
|