public subtract ( |
||
$subtrahend | ||
return |
public function subtract(Money $subtrahend)
{
$this->assertSameCurrencyAs($subtrahend);
$amount = bcsub($this->amount, $subtrahend->amount, self::SCALE);
return $this->newInstance($amount);
}
/** * Decrease this account current balance * * @param Money $amount * @throws InsufficientFunds * A member cannot withdraw more than it's account current balance */ public function withdraw(Money $amount) { if ($amount->greaterThan($this->balance)) { throw new InsufficientFunds("Cannot withdraw {$amount->getAmount()}"); } $this->balance = $this->balance->subtract($amount); }