public function reduce(BankInterface $bank = null, $toCurrency = null)
    {
        if (null === $bank) {
            $bank = static::getBank();
        }

        if (!$bank instanceof MultiCurrencyBankInterface) {
            throw new \InvalidArgumentException('The supplied bank must implement MultiCurrencyBankInterface');
        }

        $rate = $bank->getRate($this->currency, $toCurrency);

        $rounder = $bank->getRounder();
        $amount = bcmul($this->getAmount(), $rate, $rounder->getPrecision() + 1);

        return $bank->createMoney($rounder->round($amount, $toCurrency), $toCurrency);
    }
public function reduce(BankInterface $bank = null, $toCurrency = null)
    {
        if (null === $bank) {
            $bank = static::getBank();
        }

        if (!$bank instanceof MultiCurrencyBankInterface) {
            throw new \InvalidArgumentException('The supplied bank must implement MultiCurrencyBankInterface');
        }

        $rate = $bank->getRate($this->currency, $toCurrency);

        $rounder = $bank->getRounder();
        $amount = bcmul($this->getAmount(), $rate, $rounder->getPrecision() + 1);

        return $bank->createMoney($rounder->round($amount, $toCurrency), $toCurrency);
    }
public function reduce ( BankInterface $ bank = null , $ toCurrency = null ) { if ( null === $ bank ) { $ bank = static :: getBank ( ) ; } if ( ! $ bank instanceof MultiCurrencyBankInterface ) { throw new \ InvalidArgumentException ( 'The supplied bank must implement MultiCurrencyBankInterface' ) ; } $ rate = $ bank -> getRate ( $ this -> currency , $ toCurrency ) ; $ rounder = $ bank -> getRounder ( ) ; $ amount = bcmul ( $ this -> getAmount ( ) , $ rate , $ rounder -> getPrecision ( ) + 1 ) ; return $ bank -> createMoney ( $ rounder -> round ( $ amount , $ toCurrency ) , $ toCurrency ) ; }
Reduces the value of this object to the supplied currency.

@param \Dough\Bank\BankInterface $bank
@param string $toCurrency

@return MultiCurrencyMoneyInterface

@throws \InvalidArgumentException when the supplied $bank does not
support currency conversion.
Reduces the value of this object to the supplied currency .