1 | <?php |
||
27 | class TokenBucketData implements PayloadInterface |
||
28 | { |
||
29 | /** |
||
30 | * The maximum token capacity |
||
31 | * @var int |
||
32 | */ |
||
33 | protected $capacity; |
||
34 | |||
35 | /** |
||
36 | * The bucket refresh rate |
||
37 | * @var \bandwithThrottle\tokenBucket\Rate |
||
38 | */ |
||
39 | protected $rate; |
||
40 | |||
41 | /** |
||
42 | * The storage instance |
||
43 | * @var \bandwidthThrottle\tokenBucket\storage\FileStorage |
||
44 | */ |
||
45 | protected $storage; |
||
46 | |||
47 | /** |
||
48 | * Initialize $this |
||
49 | * @param int $capacity of the bucket |
||
50 | * @param \bandwithThrottle\tokenBucket\Rate |
||
51 | * @param \bandwidthThrottle\tokenBucket\storage\FileStorage |
||
52 | * @return void |
||
|
|||
53 | */ |
||
54 | public function __construct($capacity, $rate, $storage) |
||
60 | |||
61 | /** |
||
62 | * Get the token bucket capacity |
||
63 | * i.e: the maximum number of |
||
64 | * tokens available at any time. |
||
65 | * |
||
66 | * @return int |
||
67 | */ |
||
68 | public function getCapacity() |
||
72 | |||
73 | /** |
||
74 | * Get Rate instance |
||
75 | * |
||
76 | * @return \bandwidthThrottle\tokenBucket\Rate |
||
77 | */ |
||
78 | public function getRate() |
||
82 | |||
83 | /** |
||
84 | * Get the storage instance. |
||
85 | * |
||
86 | * @return \bandwithThrottle\tokenBucket\storage\FileStorage |
||
87 | */ |
||
88 | public function getStorage() |
||
92 | |||
93 | /** |
||
94 | * Implements PayloadInterface |
||
95 | * emit json payload. |
||
96 | * @return string |
||
97 | */ |
||
98 | public function toJson() |
||
102 | |||
103 | /** |
||
104 | * Implements PayloadInterface |
||
105 | * emit array payload. |
||
106 | * @return string |
||
107 | */ |
||
108 | public function toArray() |
||
112 | } |
||
113 |
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.