| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 62 | 14 | public function hit(string $key) |
|
| 63 | { |
||
| 64 | 14 | $current = $this->getCurrent($key); |
|
| 65 | |||
| 66 | 14 | if ($current >= $this->limit) { |
|
| 67 | 7 | throw RateLimitExceededException::forKey($key); |
|
| 68 | } |
||
| 69 | |||
| 70 | 14 | if (0 === $current) { |
|
| 71 | 14 | $this->init($key); |
|
| 72 | 14 | return; |
|
| 73 | } |
||
| 74 | |||
| 75 | 1 | $this->increment($key); |
|
| 76 | 1 | } |
|
| 77 | |||
| 107 |