Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
44 | 5 | private function hit(string $key, Rate $rate): int |
|
45 | { |
||
46 | 5 | if (!isset($this->store[$key])) { |
|
47 | 5 | $this->store[$key] = [ |
|
48 | 5 | 'current' => 1, |
|
49 | 5 | 'reset_time' => time() + $rate->getInterval(), |
|
50 | ]; |
||
51 | 4 | } elseif ($this->store[$key]['current'] <= $rate->getOperations()) { |
|
52 | 4 | $this->store[$key]['current']++; |
|
53 | } |
||
54 | |||
55 | 5 | return $this->store[$key]['current']; |
|
56 | } |
||
57 | } |
||
58 |