src/Money.php
public function convertedTo($currency, $exchangeRate, Context $context = null, int $roundingMode = RoundingMode::UNNECESSARY) : Money
    {
        if (! $currency instanceof Currency) {
            $currency = Currency::of($currency);
        }

        if ($context === null) {
            $context = $this->context;
        }

        $amount = $this->amount->toBigRational()->multipliedBy($exchangeRate);

        return self::create($amount, $currency, $context, $roundingMode);
    }
public function convertedTo($currency, $exchangeRate, Context $context = null, int $roundingMode = RoundingMode::UNNECESSARY) : Money
    {
        if (! $currency instanceof Currency) {
            $currency = Currency::of($currency);
        }

        if ($context === null) {
            $context = $this->context;
        }

        $amount = $this->amount->toBigRational()->multipliedBy($exchangeRate);

        return self::create($amount, $currency, $context, $roundingMode);
    }
public function convertedTo ( $ currency , $ exchangeRate , Context $ context = null , int $ roundingMode = RoundingMode :: UNNECESSARY ) : Money { if ( ! $ currency instanceof Currency ) { $ currency = Currency :: of ( $ currency ) ; } if ( $ context === null ) { $ context = $ this -> context ; } $ amount = $ this -> amount -> toBigRational ( ) -> multipliedBy ( $ exchangeRate ) ; return self :: create ( $ amount , $ currency , $ context , $ roundingMode ) ; }
Converts this Money to another currency, using an exchange rate.

By default, the resulting Money has the same context as this Money.
This can be overridden by providing a Context.

For example, converting a default money of `USD 1.23` to `EUR` with an exchange rate of `0.91` and
RoundingMode::UP will yield `EUR 1.12`.

@param Currency|string|int     $currency     The Currency instance, ISO currency code or ISO numeric currency code.
@param BigNumber|number|string $exchangeRate The exchange rate to multiply by.
@param Context|null            $context      An optional context.
@param int                     $roundingMode An optional rounding mode.

@return Money

@throws UnknownCurrencyException If an unknown currency code is given.
@throws MathException            If the exchange rate or rounding mode is invalid, or rounding is necessary.
Converts this Money to another currency using an exchange rate .