/** * Subtracts a Money and returns the result as a new Money * * @param MoneyInterface $other Other money * * @return MoneyInterface New money instance as a result of subtraction * between current object and given as a parameter */ public function subtract(MoneyInterface $other) { $wrappedMoney = $this->wrappedMoney->subtract($this->newWrappedMoneyFromMoney($other)); return Money::create($wrappedMoney->getAmount(), $other->getCurrency()); }
/** * {@inheritdoc} */ public function subtract(Money $other) { $toSub = new BaseMoney($other->getAmount(), $other->getCurrency()); $result = $this->valueObject->subtract($toSub); return new static(['amount' => $result->getAmount(), 'currency' => $this->currency]); }