= 10000 || $fixedMinor < 0 ) { throw new \InvalidArgumentException( 'Invalid fee rates.' ); } } /** Total the donor pays so the recipient nets $baseMinor. */ public function grossUp( int $baseMinor ): int { if ( $baseMinor <= 0 ) { return 0; } $num = ( $baseMinor + $this->fixedMinor ) * 10000; $den = 10000 - $this->percentBps; return intdiv( $num + $den - 1, $den ); // integer ceil } /** The extra fee-cover portion for a base amount. */ public function feeFor( int $baseMinor ): int { return $this->grossUp( $baseMinor ) - $baseMinor; } }