You are here

public static function Input::parseAmount in Currency 7.2

Parses an amount.

Parameters

string|int|float $amount: Any optionally localized numeric value.

Return value

string A numeric string.

Throws

AmountNotNumericException

4 calls to Input::parseAmount()
currency_form_currency_amount_validate in currency/currency.module
Implements form validate callback for a currency_amount element.
InputTest::testParseAmount in currency/vendor/bartfeenstra/currency/src/BartFeenstra/Tests/Currency/InputTest.php
Tests amount().
_currency_filter_currency_exchange_process in currency/currency.module
Implements preg_replace_callback() callback.
_currency_filter_currency_localize_process in currency/currency.module
Implements preg_replace_callback() callback.

File

currency/vendor/bartfeenstra/currency/src/BartFeenstra/Currency/Input.php, line 36
Contains class \BartFeenstra\Currency\Input.

Class

Input
Helpers for parsing user input.

Namespace

BartFeenstra\Currency

Code

public static function parseAmount($amount) {
  if (!is_numeric($amount)) {
    $amount = self::parseAmountDecimalSeparator($amount);
    $amount = self::parseAmountNegativeFormat($amount);
  }
  if (!is_numeric($amount)) {
    throw new AmountNotNumericException('The amount could not be interpreted as a numeric string.');
  }
  return (string) $amount;
}