1 | <?php |
||
18 | abstract class AbstractRateLimiter implements RateLimiterInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var int |
||
22 | */ |
||
23 | protected $limit; |
||
24 | |||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | protected $window; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $key; |
||
34 | |||
35 | 24 | public function __construct($limit, $window) |
|
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | 8 | public function getLimit() |
|
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 2 | public function getWindow() |
|
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | 14 | public function hit($key) |
|
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | 10 | public function getRemainingAttempts($key) |
|
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | 10 | public function getResetAt($key) |
|
92 | |||
93 | 14 | protected function getCurrent($key) |
|
97 | |||
98 | abstract protected function get($key, $default); |
||
99 | |||
100 | abstract protected function init($key); |
||
101 | |||
102 | abstract protected function increment($key); |
||
103 | |||
104 | abstract protected function ttl($key); |
||
105 | } |
||
106 |