Responsibility: try to parse floating point number from raw user input string by locale conventions by Intl
extension or by automatic floating point detection (which looks more successful). If there is not possible to get float
value, return NULL
.
Methods summary
public static
|
#
CreateInstance( string $lang = 'en', string $locale = 'US', boolean $preferIntlParsing = FALSE )
Create new instance of floating point number parser.
Create new instance of floating point number parser.
Parameters
- $lang
- Language international code, lower case, example:
"en" | "de" .
- $locale
- Country/locale code, upper case, example:
"US" | "UK" .
- $preferIntlParsing
Boolean flag to prefer Intl extension parsing if Intl extension (bundled in PHP from 5.3).
Default is FALSE to prefer parsing by automatic floating point detection.
|
public
|
#
__construct( string $lang = 'en', string $locale = 'US', boolean $preferIntlParsing = FALSE )
Create new instance of floating point number parser.
Create new instance of floating point number parser.
Parameters
- $lang
- Language international code, lower case, example:
"en" | "de" .
- $locale
- Country/locale code, upper case, example:
"US" | "UK" .
- $preferIntlParsing
Boolean flag to prefer Intl extension parsing if Intl extension (bundled in PHP from 5.3).
Default is TRUE to prefer parsing by automatic floating point detection.
|
public
MvcCore\Ext\Tools\Locales\FloatParser
|
#
SetLang( string|null $lang )
Set language international code, lower case, example: "en" | "de" .
Set language international code, lower case, example: "en" | "de" .
Parameters
Returns
|
public
string|null
|
#
GetLang( )
Get language international code, lower case, example: "en" | "de" .
Get language international code, lower case, example: "en" | "de" .
Returns
string|null
|
public
MvcCore\Ext\Tools\Locales\FloatParser
|
#
SetLocale( string|null $locale )
Set country/locale code, upper case, example: "US" | "UK" .
Set country/locale code, upper case, example: "US" | "UK" .
Parameters
Returns
|
public
string|null
|
#
GetLocale( )
Get country/locale code, upper case, example: "US" | "UK" .
Get country/locale code, upper case, example: "US" | "UK" .
Returns
string|null
|
public
MvcCore\Ext\Tools\Locales\FloatParser
|
#
SetPreferIntlParsing( boolean $preferIntlParsing = FALSE )
Set boolean flag about to prefer Intl extension parsing (bundled in PHP from 5.3).
Default is FALSE to prefer parsing by automatic floating point detection.
Set boolean flag about to prefer Intl extension parsing (bundled in PHP from 5.3).
Default is FALSE to prefer parsing by automatic floating point detection.
Parameters
Returns
|
public
boolean
|
#
GetPreferIntlParsing( )
Get boolean flag about to prefer Intl extension parsing (bundled in PHP from 5.3).
Default is FALSE to prefer parsing by automatic floating point detection.
Get boolean flag about to prefer Intl extension parsing (bundled in PHP from 5.3).
Default is FALSE to prefer parsing by automatic floating point detection.
Returns
boolean
|
public
float|null
|
#
Parse( string $rawInput )
Try to parse floating point number from raw user input string
by locale conventions by Intl extension or by automatic
floating point detection (which looks more successful).
If there is not possible to get float value, return NULL .
Try to parse floating point number from raw user input string
by locale conventions by Intl extension or by automatic
floating point detection (which looks more successful).
If there is not possible to get float value, return NULL .
If Intl extension installed and if Intl extension parsing preferred,
try to parse by Intl extension integer first, than floating point number,
but always return floating point number type.
If not preferred or not installed, try to determinate floating point in
user input string automatically and use PHP floatval() to parse the result.
If parsing by floatval returns NULL and Intl extension is installed
but not preferred, try to parse user input by Intl extension after it.
This function do not throw any exception outside.
All possible exceptions are caught inside the class.
Parameters
Returns
float|null
|
protected
float|null
|
#
parseByIntl( string $rawInput )
Parse user input by Intl extension and try to return int or float .
Parse user input by Intl extension and try to return int or float .
Parameters
Returns
float|null
|
protected
integer|null
|
#
parseIntegerByIntl( string $rawInput, $langAndLocale )
Parse user input by Intl extension and try to return int .
Parse user input by Intl extension and try to return int .
Parameters
Returns
integer|null
|
protected
float|null
|
#
parseFloatByIntl( string $rawInput, $langAndLocale )
Parse user input by Intl extension and try to return float .
Parse user input by Intl extension and try to return float .
Parameters
Returns
float|null
|
protected
float|null
|
#
parseByFloatVal( string $rawInput )
Try to determinate floating point separator if any
and try to parse user input by floatval() PHP function.
Try to determinate floating point separator if any
and try to parse user input by floatval() PHP function.
Parameters
Returns
float|null
|