1 | <?php |
||
9 | abstract class AbstractElapsedTimeRateLimiter implements RateLimiter, SilentRateLimiter |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $keyPrefix; |
||
15 | |||
16 | public function __construct(string $keyPrefix = '') |
||
20 | |||
21 | final public function limit(string $identifier, Rate $rate): void |
||
34 | |||
35 | final public function limitSilently(string $identifier, Rate $rate): Status |
||
53 | |||
54 | private function valueKey(string $identifier, int $interval): string |
||
58 | |||
59 | private function timeKey(string $identifier, int $interval): string |
||
63 | |||
64 | abstract protected function getCurrent(string $valueKey): int; |
||
65 | |||
66 | abstract protected function updateCounter(string $valueKey, string $timeKey, int $interval): int; |
||
67 | |||
68 | abstract protected function getElapsedTime(string $timeKey): int; |
||
69 | } |
||
70 |