1 | <?php |
||
27 | class RateData implements PayloadInterface |
||
28 | { |
||
29 | /** |
||
30 | * The rate limit |
||
31 | * i.e. capacity of the token-bucket |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $limit; |
||
35 | |||
36 | /** |
||
37 | * The time period constant from Rate |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $period; |
||
41 | |||
42 | /** |
||
43 | * Initialize $this |
||
44 | * @param int $limit capacity |
||
45 | * @param string $period Rate::<CONSTANT> |
||
46 | * @return void |
||
|
|||
47 | */ |
||
48 | public function __construct($limit, $period) |
||
53 | |||
54 | /** |
||
55 | * Get the token bucket capacity |
||
56 | * i.e: the maximum number of |
||
57 | * tokens available at any time. |
||
58 | * @return |
||
59 | */ |
||
60 | public function getLimit() |
||
64 | |||
65 | /** |
||
66 | * Get the constant name for the |
||
67 | * time period between |
||
68 | * bucket refill. |
||
69 | * e.g: 'SECOND' | 'DAY' ... |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | public function getPeriod() |
||
77 | |||
78 | /** |
||
79 | * Implements PayloadInterface |
||
80 | * emit json payload. |
||
81 | * @return string |
||
82 | */ |
||
83 | public function toJson() |
||
87 | |||
88 | /** |
||
89 | * Implements PayloadInterface |
||
90 | * emit array payload. |
||
91 | * @return string |
||
92 | */ |
||
93 | public function toArray() |
||
97 | } |
||
98 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.