Пример #1
0
 /**
  * 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);
 }
Пример #2
0
 /**
  * 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);
 }
Пример #3
0
 /**
  * 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));
 }