<?php

class CurrencyFactory {

    public static function returnPriceInDefaultCurrencyValue($from, $current_value) {
        $currency = new Currency();
        $result = $currency->returnExchangedCurrencyValue($from, $current_value);
        return $result;
    }

    public static function returnExchangedValueByExchangedID($exchanged_id, $current_value, $from_currency) {
        $currency = new Currency();
        $result = $currency->returnExchangedValueByExchangedID($exchanged_id, $current_value, $from_currency);
        return $result;
    }

    public static function returnExchangedValueBetweenTwoCurrencies($from, $to, $current_value) {
        $currency = new Currency();
        $result = $currency->returnExchangedBetweenTwoCurrencies($from, $to, $current_value);
        return $result;
    }

    public static function getCurrencySymbol($currency_id) {
        $currency = new Currency();
        return $currency->viewCurrencySymbol($currency_id);
    }

    public static function getDefaultCurrency() {
        $currency = new Currency();
        return $currency->getDefaultCurrency();
    }

    public static function getDefaultCurrencySymbol() {
        $default = self::getDefaultCurrency();
        return self::getCurrencySymbol($default);
    }

    public static function getLocalCurrencySymbol() {
        $local = self::returnLocalCurrency();
        return self::getCurrencySymbol($local);
    }

    public static function returnLocalCurrency() {
        $currency = new Currency();
        return $currency->returnLocalCurrency();
    }

    public static function getCurrencyByPlacement($placement) {
        $currency = new Currency();
        return $currency->getCurrencyByPlacement($placement);
    }

    public static function getDefaultCurrencyById($id) {
        $currency = new Currency();
        return $currency->getDefaultCurrencyById($id);
    }

    public static function GetLIListCurrency($id = null) {
        $currency = new Currency();
        return $currency->GetLIListCurrency($id);
    }

    public static function getCurrencyCodeByID($id) {
        $currency = new Currency();
        return $currency->getCurrencyCodeByID($id);
    }

    public static function getLastExRate($currency_id) {
        $currency = new Currency();
        return $currency->getLastExRate($currency_id);
    }

    public static function getSecondCurrencyLastExRate($currency_id) {
        $currency = new Currency();
        return $currency->getSecondCurrencyLastExRate($currency_id);
    }

    public static function returnLocalCurrencyValue($from, $current_value) {
        $currency = new Currency();
        $result = $currency->returnLocalCurrencyValue($from, $current_value);
        return $result;
    }

    public static function getCurrencyTimeExchangeRate($from, $to, $record_date) {
//        echo $from.'=='.$to.'=='.$record_date;
//        die();
        if($from==$to)
            return 1;
        $currency = new Currency();
        $exc_arr = $currency->getCurrencyTimeExchangeRate($from, $to, $record_date);
        if (empty($exc_arr['rate']))
            return 0;
        if ($exc_arr['operation'] == '/')
            return (1 / $exc_arr['rate']);
//        echo $exc_arr['rate'];
//        die();
        return $exc_arr['rate'];
    }

    public static function convertCurrencyTimeExchangeRate($from, $to, $amount, $record_date) {
        $currency = new Currency();
        return $currency->convertCurrencyTimeExchangeRate($from, $to, $amount, $record_date);
    }

    public static function returnExchangeRate($from, $to) {
        $currency = new Currency();
        return $currency->returnExchangeRate($from, $to);
    }

}
