15 private $defaultAmount;
18 private $operations = [];
30 $this->limiter = $limiter;
31 $this->defaultAmount = $defaultAmount;
43 public function localOp( $condName, $components = [], $amount =
null ) {
44 if ( !is_array( $components ) ) {
45 $components = [ $components ];
64 public function globalOp( $condName, $components = [], $amount =
null ) {
65 if ( !is_array( $components ) ) {
66 $components = [ $components ];
76 private function queueOp(
$type, $entity, $amount ) {
77 $amount ??= $this->defaultAmount;
78 if ( isset( $this->operations[
$type] ) ) {
80 ': cannot queue multiple actions of the same type, ' .
81 'since the result array is indexed by type' );
83 $this->operations[
$type] =
new LimitOperation(
$type, $entity, $amount );
93 return $this->limiter->peekBatch( $this->operations );
100 $this->limiter->incrBatch( $this->operations );
112 return $this->limiter->tryIncrBatch( $this->operations );