1 | <?php |
||
31 | abstract class AbstractWindowThrottler |
||
32 | { |
||
33 | /** |
||
34 | * @var CacheAdapterInterface |
||
35 | */ |
||
36 | protected $cache; |
||
37 | |||
38 | /** |
||
39 | * @var int|null |
||
40 | */ |
||
41 | protected $cacheTtl; |
||
42 | |||
43 | /** |
||
44 | * @var int |
||
45 | */ |
||
46 | protected $hitLimit; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $key; |
||
52 | |||
53 | /** |
||
54 | * @var int |
||
55 | */ |
||
56 | protected $timeLimit; |
||
57 | |||
58 | /** |
||
59 | * @var TimeAdapterInterface |
||
60 | */ |
||
61 | protected $timeProvider; |
||
62 | |||
63 | /** |
||
64 | * @param CacheAdapterInterface $cache |
||
65 | * @param TimeAdapterInterface $timeAdapter |
||
66 | * @param string $key Cache key prefix |
||
67 | * @param int $hitLimit Maximum number of hits |
||
68 | * @param int $timeLimit Length of window |
||
69 | * @param int|null $cacheTtl Cache ttl time (default: null => CacheAdapter ttl) |
||
70 | */ |
||
71 | 36 | public function __construct( |
|
86 | |||
87 | /** |
||
88 | * @inheritdoc |
||
89 | */ |
||
90 | 6 | public function access() |
|
97 | |||
98 | |||
99 | /** |
||
100 | * @inheritdoc |
||
101 | */ |
||
102 | 19 | public function check() |
|
106 | |||
107 | /** |
||
108 | * @inheritdoc |
||
109 | */ |
||
110 | public function getTime() |
||
114 | |||
115 | /** |
||
116 | * @inheritdoc |
||
117 | */ |
||
118 | public function getLimit() |
||
122 | |||
123 | /** |
||
124 | * @inheritdoc |
||
125 | */ |
||
126 | abstract public function hit(); |
||
127 | |||
128 | /** |
||
129 | * @inheritdoc |
||
130 | */ |
||
131 | abstract public function count(); |
||
132 | } |
||
133 |