/** * Reduces the supplied monetary object into a single * Money object of the supplied currency. * * @param \Dough\Money\MoneyInterface $source * @param string|null $toCurrency * * @return Money * * @throws \Dough\Exception\InvalidCurrencyException when a supplied currency is * unknown. */ public function reduce(MoneyInterface $source, $toCurrency = null) { if (null === $toCurrency) { $toCurrency = $this->getBaseCurrency(); } $this->checkCurrencies($toCurrency); return $source->reduce($this, $toCurrency); }
/** * Reduces the supplied monetary object into a single * Money object. * * @param \Dough\Money\MoneyInterface $source * * @return \Dough\Money\Money */ public function reduce(MoneyInterface $source) { return $source->reduce($this); }
/** * Subtracts the subtrahend from the money object. * * The subtrahend should be passed in as a positive value. * * @param MoneyInterface $subtrahend * @return Sum */ public function subtract(MoneyInterface $subtrahend) { return $this->plus($subtrahend->times(-1)); }