carryOver ? $carry : 0 ) + $d->amountFor( $this->basis ); $delta = intdiv( $pool, $this->perMinor ) * $this->step; return array( 'delta' => $delta, 'counter' => $counter + $delta, 'carry' => $this->carryOver ? $pool % $this->perMinor : 0, ); } /** @return array{counter:int, carry:int} Counter floors at 0; carry is rolled back by the donation amount. */ public function reverse( Donation $d, int $delta, int $counter, int $carry ): array { $carry = $this->carryOver ? ( ( $carry - $d->amountFor( $this->basis ) ) % $this->perMinor + $this->perMinor ) % $this->perMinor : 0; return array( 'counter' => max( 0, $counter - $delta ), 'carry' => $carry ); } }