1 | <?php |
||
13 | class ThrottleMiddleware |
||
14 | { |
||
15 | /** |
||
16 | * @var ThrottleConfiguration[] |
||
17 | */ |
||
18 | private $configurations = []; |
||
19 | |||
20 | /** |
||
21 | * @var ThrottleStorageInterface |
||
22 | */ |
||
23 | private $storage; |
||
24 | |||
25 | /** |
||
26 | * @var LoggerInterface |
||
27 | */ |
||
28 | private $logger; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $logLevel; |
||
34 | |||
35 | /** |
||
36 | * ThrottleMiddleware constructor. |
||
37 | * @param ThrottleStorageInterface $storage |
||
38 | * @param LoggerInterface|null $logger |
||
39 | * @param string $logLevel |
||
40 | */ |
||
41 | public function __construct(ThrottleStorageInterface $storage = null, LoggerInterface $logger = null, string $logLevel = LogLevel::INFO) |
||
47 | |||
48 | /** |
||
49 | * @param ThrottleConfiguration $configuration |
||
50 | */ |
||
51 | public function registerConfiguration(ThrottleConfiguration $configuration) |
||
55 | |||
56 | |||
57 | public function __invoke(callable $handler) |
||
69 | |||
70 | private function processConfiguration(ThrottleConfiguration $configuration) |
||
100 | |||
101 | /** |
||
102 | * @param float $value |
||
103 | */ |
||
104 | private function sleep(float $value) |
||
115 | } |
||
116 |