1 | <?php |
||
9 | class Rate |
||
10 | { |
||
11 | /** @var int */ |
||
12 | protected $operations; |
||
13 | |||
14 | /** @var int */ |
||
15 | protected $interval; |
||
16 | |||
17 | 10 | final protected function __construct(int $operations, int $interval) |
|
25 | |||
26 | 3 | public static function perSecond(int $operations) |
|
30 | |||
31 | 2 | public static function perMinute(int $operations) |
|
35 | |||
36 | 3 | public static function perHour(int $operations) |
|
40 | |||
41 | 1 | public static function perDay(int $operations) |
|
42 | { |
||
43 | 1 | return new static($operations, 86400); |
|
44 | } |
||
45 | |||
46 | 1 | public static function custom(int $operations, int $interval) |
|
47 | { |
||
48 | 1 | return new static($operations, $interval); |
|
49 | } |
||
50 | |||
51 | 10 | public function getOperations(): int |
|
55 | |||
56 | 10 | public function getInterval(): int |
|
60 | } |
||
61 |