1 | <?php |
||
5 | class LimitedApiRate implements ApiRate |
||
6 | { |
||
7 | /** @var int */ |
||
8 | private $limit; |
||
9 | |||
10 | /** @var int */ |
||
11 | private $remaining; |
||
12 | |||
13 | /** @var \DateTimeInterface */ |
||
14 | private $reset; |
||
15 | |||
16 | /** |
||
17 | * LimitedApiRate constructor. |
||
18 | * |
||
19 | * @param int $limit |
||
20 | * @param int $remaining |
||
21 | * @param int $reset |
||
22 | */ |
||
23 | 3 | public function __construct( |
|
24 | $limit, |
||
25 | $remaining, |
||
26 | $reset |
||
27 | ) { |
||
28 | 3 | $this->limit = $limit; |
|
29 | 3 | $this->remaining = $remaining; |
|
30 | 3 | $this->reset = \DateTimeImmutable::createFromFormat( |
|
31 | 3 | 'U', |
|
32 | 3 | $reset, |
|
33 | 3 | new \DateTimeZone('UTC') |
|
34 | 2 | ); |
|
35 | 3 | } |
|
36 | |||
37 | /** |
||
38 | * @return int |
||
39 | */ |
||
40 | public function getLimit() |
||
44 | |||
45 | /** |
||
46 | * @return bool |
||
47 | */ |
||
48 | public function canMakeAnotherCall() |
||
52 | |||
53 | /** |
||
54 | * @return \DateTimeInterface |
||
55 | */ |
||
56 | 3 | public function nextWindow() |
|
60 | } |
||
61 |