Function to set currency.

@param string $currency

@throws \Exception

@return $this
4248
public function setCurrency($currency = 'USD')
    {
        $allowedCurrencies = ['AUD', 'BRL', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'INR', 'JPY', 'MYR', 'MXN', 'NOK', 'NZD', 'PHP', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'TWD', 'THB', 'USD', 'RUB'];

        // Check if provided currency is valid.
        if (!in_array($currency, $allowedCurrencies)) {
            throw new \Exception('Currency is not supported by PayPal.');
        }

        $this->currency = $currency;

        return $this;
    }
836727
public function set(CurrencyInterface $currency)
    {
        $this
            ->session
            ->set(
                $this->sessionFieldName,
                $currency->getIso()
            );

        return $this;
    }
577517
public function setPrice($price)
    {
        NumericValidator::validate($price, "Price");
        $price = Formatter::formatToPrice($price, $this->getCurrency());
        $this->price = $price;
        return $this;
    }
527651
protected function updateCurrencyRates(Currency $currency)
    {
        $baseExchangeRate = $this->table[$currency->getCode()];

        foreach ($this->table as $currencySymbol => $exchangeRate) {
            $rate = $this->calculateExchangeRate($baseExchangeRate, $currencySymbol);
            $this->addUpdateExchangeRate($currency->getCode(), $currencySymbol, $rate);
        }

        $this->helper->getEntityManager()->flush();
    }
637423
public function set(string $currency): void
    {
        $this->request->session()->put(
            $this->config->key,
            $this->value($currency)
        );
    }
1172825
public function setRetailPrice(Money $retailPrice): self
    {
        $this->updateCurrency($retailPrice);
        $this->retailPrice = (int) $retailPrice->getAmount();
        $this->updateTotalRetailPrice();

        return $this;
    }
958386
private function initializeNode(Currency $currency)
    {
        $node = new \stdClass();

        $node->currency = $currency;
        $node->discovered = false;
        $node->parent = null;

        return $node;
    }
70983
@Override
    public MonetaryAmountFactory<T> setCurrency(String currencyCode) {
        this.currency = Monetary.getCurrency(currencyCode);
        return this;
    }
986136
public function currency($currency = null) {
        $currency = $currency == null ? $this->currency : $currency;
        return $this->getWord($this->number) . ' ' . $currency;
    }
1280423
public function setAmount($amount)
    {
        if ($amount instanceof DBMoney) {
            $this->setField('Money', $amount);
        } elseif ($this->Status == 'Created' && is_numeric($amount)) {
            $this->MoneyAmount = $amount;
        }
        return $this;
    }
143553
public function setValue($value)
    {
        if (is_scalar($value)) {
            $this->value = new StringValue($value);
        } elseif (is_array($value)) {
            $this->value = new ArrayValue($value);
        } else {
            if (!$value instanceof ValueInterface) {
                throw new \Exception('The value must implement the ValueInterface.');
            } else {
                $this->value = $value;
            }
        }

        return $this;
    }
1283635
public function setValue($value, $data = null)
    {
        if (!$value) {
            $value = 0.00;
        }
        $this->value = DBCurrency::config()->uninherited('currency_symbol')
            . number_format((double)preg_replace('/[^0-9.\-]/', '', $value), 2);
        return $this;
    }
1201016
public function fromFloat($amount, $currency = null)
    {
        if ($currency) {
            $this->setCurrency($currency);
        }

        if (!is_float($amount)) {
            throw new InvalidArgumentException(sprintf(
                'Amount must be a float, %s given',
                gettype($amount)
            ));
        }
        
        $this->amount = $this->toInt(
            round(
                $this->getSubUnit() * round($amount, $this->getFractionDigits(), PHP_ROUND_HALF_UP),
                0,
                PHP_ROUND_HALF_UP
            )
        );
        return $this;
    }
969548
public function setCurrencyCode($currencyCode): self
    {
        if ($currencyCode instanceof RowColumn) {
            $this->currency_column = $currencyCode->getColumnName();
        } elseif (!is_string($currencyCode) || trim($currencyCode) === '') {
            throw new Exception\InvalidArgumentException(__METHOD__ . ' Currency code must be an non empty string (or a RowColumn object)');
        }
        $this->params['currency_code'] = $currencyCode;

        return $this;
    }
147105
static function withOrderNumberAmountAndCurrency($orderNumber, $amount, $currency)
    {
        return (new static())
            ->setOrderNumber($orderNumber)
            ->setAmount($amount)
            ->setCurrency($currency)
            ;
    }
366441
public static function withSecure($amount, Currency $currency = null)
    {
        if(!is_long($amount))
            throw new InvalidAmountException;
        $money = self::withRaw(0, $currency);
        $money->setFraction($amount / 100);
        $money->setWhole($amount / 100);
        return $money;
    }
379896
private function _checkCurrency(&$currency)
    {
        if (!isset($currency)) {
            throw new Klarna_ArgumentNotSetException("Currency");
        }
        if (is_numeric($currency) && !is_int($currency)) {
            $currency = intval($currency);
        }
        if (!is_numeric($currency) || !is_int($currency)) {
            throw new Klarna_InvalidTypeException("Currency", "integer");
        }
    }