public function convert(Money $amount, IdentifierInterface $to)
    {
        if (!$toCurrency = $this->getCurrency($to)) {
            throw new \InvalidArgumentException("Currency not supported");
        }

        /** @var \Heystack\Ecommerce\Currency\Interfaces\CurrencyInterface $fromCurrency */
        $fromCurrency = $amount->getCurrency();

        return $amount->multiply($toCurrency->getValue() / $fromCurrency->getValue());
    }
public function convert(Money $amount, IdentifierInterface $to)
    {
        if (!$toCurrency = $this->getCurrency($to)) {
            throw new \InvalidArgumentException("Currency not supported");
        }

        /** @var \Heystack\Ecommerce\Currency\Interfaces\CurrencyInterface $fromCurrency */
        $fromCurrency = $amount->getCurrency();

        return $amount->multiply($toCurrency->getValue() / $fromCurrency->getValue());
    }
public function convert ( Money $ amount , IdentifierInterface $ to ) { if ( ! $ toCurrency = $ this -> getCurrency ( $ to ) ) { throw new \ InvalidArgumentException ( "Currency not supported" ) ; } /** @var \Heystack\Ecommerce\Currency\Interfaces\CurrencyInterface $fromCurrency */ $ fromCurrency = $ amount -> getCurrency ( ) ; return $ amount -> multiply ( $ toCurrency -> getValue ( ) / $ fromCurrency -> getValue ( ) ) ; }
Converts amount from one currency to another using the currency's identifier

Warning this method can lose precision!

@param  \SebastianBergmann\Money\Money $amount
@param  \Heystack\Core\Identifier\IdentifierInterface $to
@return \SebastianBergmann\Money\Money
@throws \InvalidArgumentException
Converts amount from one currency to another using the currency s identifier