Documentation

FormattedNumber
in package

Table of Contents

Constants

CURRENCY_CONVERSION_LIST  = '\\$€£¥%s'
STRING_CONVERSION_LIST  = [[self::class, 'convertToNumberIfNumeric'], [self::class, 'convertToNumberIfFraction'], [self::class, 'convertToNumberIfPercent'], [self::class, 'convertToNumberIfCurrency']]
STRING_REGEXP_FRACTION  = '~^\\s*(-?)((\\d*)\\s+)?(\\d+\\/\\d+)\\s*$~'
Regular Expressions
STRING_REGEXP_PERCENT  = '~^(?:(?: *(?<PrefixedSign>[-+])? *\\% *(?<PrefixedSign2>[-+])? *(?<PrefixedValue>[0-9]+\\.?[0-9*]*(?:E[-+]?[0-9]*)?) *)|(?: *(?<PostfixedSign>[-+])? *(?<PostfixedValue>[0-9]+\\.?[0-9]*(?:E[-+]?[0-9]*)?) *\\% *))$~i'

Methods

convertToNumberIfCurrency()  : bool
Identify whether a string contains a currency value, and if so, convert it to a numeric.
convertToNumberIfFormatted()  : bool
Identify whether a string contains a formatted numeric value, and convert it to a numeric if it is.
convertToNumberIfFraction()  : bool
Identify whether a string contains a fractional numeric value, and convert it to a numeric if it is.
convertToNumberIfNumeric()  : bool
Identify whether a string contains a numeric value, and convert it to a numeric if it is.
convertToNumberIfPercent()  : bool
Identify whether a string contains a percentage, and if so, convert it to a numeric.
currencyMatcherRegexp()  : string

Constants

CURRENCY_CONVERSION_LIST

private mixed CURRENCY_CONVERSION_LIST = '\\$€£¥%s'

STRING_CONVERSION_LIST

private mixed STRING_CONVERSION_LIST = [[self::class, 'convertToNumberIfNumeric'], [self::class, 'convertToNumberIfFraction'], [self::class, 'convertToNumberIfPercent'], [self::class, 'convertToNumberIfCurrency']]

STRING_REGEXP_FRACTION

Regular Expressions

private mixed STRING_REGEXP_FRACTION = '~^\\s*(-?)((\\d*)\\s+)?(\\d+\\/\\d+)\\s*$~'

STRING_REGEXP_PERCENT

private mixed STRING_REGEXP_PERCENT = '~^(?:(?: *(?<PrefixedSign>[-+])? *\\% *(?<PrefixedSign2>[-+])? *(?<PrefixedValue>[0-9]+\\.?[0-9*]*(?:E[-+]?[0-9]*)?) *)|(?: *(?<PostfixedSign>[-+])? *(?<PostfixedValue>[0-9]+\\.?[0-9]*(?:E[-+]?[0-9]*)?) *\\% *))$~i'

Methods

convertToNumberIfCurrency()

Identify whether a string contains a currency value, and if so, convert it to a numeric.

public static convertToNumberIfCurrency(string &$operand) : bool
Parameters
$operand : string

string value to test

Return values
bool

convertToNumberIfFormatted()

Identify whether a string contains a formatted numeric value, and convert it to a numeric if it is.

public static convertToNumberIfFormatted(string &$operand) : bool
Parameters
$operand : string

string value to test

Return values
bool

convertToNumberIfFraction()

Identify whether a string contains a fractional numeric value, and convert it to a numeric if it is.

public static convertToNumberIfFraction(string &$operand) : bool
Parameters
$operand : string

string value to test

Return values
bool

convertToNumberIfNumeric()

Identify whether a string contains a numeric value, and convert it to a numeric if it is.

public static convertToNumberIfNumeric(string &$operand) : bool
Parameters
$operand : string

string value to test

Return values
bool

convertToNumberIfPercent()

Identify whether a string contains a percentage, and if so, convert it to a numeric.

public static convertToNumberIfPercent(string &$operand) : bool
Parameters
$operand : string

string value to test

Return values
bool

currencyMatcherRegexp()

public static currencyMatcherRegexp() : string
Return values
string

        
On this page

Search results