public function convert($amount, $from = null, $to = null, $format = TRUE)
    {
        // Get currencies involved
        $from = $from ?: $this->config('default');
        $to = $to ?: $this->getUserCurrency();

        // Get exchange rates
        $from_rate = $this->getCurrencyProp($from, 'currency_rate');
        $to_rate = $this->getCurrencyProp($to, 'currency_rate');

        // Skip invalid to currency rates
        if ($to_rate === null) {
            return null;
        }

        // Convert amount
        $value = $amount * $to_rate * (1 / $from_rate);

        // Should the result be formatted?
        if ($format === TRUE) {
            return $this->format($value, $to);
        }

        // Return value
        return $value;
    }
public function convert($amount, $from = null, $to = null, $format = TRUE)
    {
        // Get currencies involved
        $from = $from ?: $this->config('default');
        $to = $to ?: $this->getUserCurrency();

        // Get exchange rates
        $from_rate = $this->getCurrencyProp($from, 'currency_rate');
        $to_rate = $this->getCurrencyProp($to, 'currency_rate');

        // Skip invalid to currency rates
        if ($to_rate === null) {
            return null;
        }

        // Convert amount
        $value = $amount * $to_rate * (1 / $from_rate);

        // Should the result be formatted?
        if ($format === TRUE) {
            return $this->format($value, $to);
        }

        // Return value
        return $value;
    }
public function convert ( $ amount , $ from = null , $ to = null , $ format = TRUE ) { // Get currencies involved $ from = $ from ? : $ this -> config ( 'default' ) ; $ to = $ to ? : $ this -> getUserCurrency ( ) ; // Get exchange rates $ from_rate = $ this -> getCurrencyProp ( $ from , 'currency_rate' ) ; $ to_rate = $ this -> getCurrencyProp ( $ to , 'currency_rate' ) ; // Skip invalid to currency rates if ( $ to_rate === null ) { return null ; } // Convert amount $ value = $ amount * $ to_rate * ( 1 / $ from_rate ) ; // Should the result be formatted? if ( $ format === TRUE ) { return $ this -> format ( $ value , $ to ) ; } // Return value return $ value ; }
Format given number.

@param float $amount
@param string $from
@param string $to
@param bool $format

@return string
Format given number .