15 private $defaultAmount;
18 private $operations = [];
29 $this->limiter = $limiter;
30 $this->defaultAmount = $defaultAmount;
42 public function localOp( $condName, $components = [], $amount =
null ) {
43 if ( !is_array( $components ) ) {
44 $components = [ $components ];
63 public function globalOp( $condName, $components = [], $amount =
null ) {
64 if ( !is_array( $components ) ) {
65 $components = [ $components ];
75 private function queueOp( $type, $entity, $amount ) {
76 $amount ??= $this->defaultAmount;
77 if ( isset( $this->operations[$type] ) ) {
78 throw new WRStatsError(
'Cannot queue multiple actions of the same type, ' .
79 'because the result array is indexed by type' );
81 $this->operations[$type] =
new LimitOperation( $type, $entity, $amount );
91 return $this->limiter->peekBatch( $this->operations );
98 $this->limiter->incrBatch( $this->operations );
110 return $this->limiter->tryIncrBatch( $this->operations );