public function NumberFormatter::parse in Physical Fields 8
Parses the given number.
Replaces language-specific characters with the standard ones.
Parameters
string $number: The number, formatted according to the current language.
Return value
string|false The parsed number, or FALSE on error.
Overrides NumberFormatterInterface::parse
File
- src/
NumberFormatter.php, line 72
Class
- NumberFormatter
- Default number formatter.
Namespace
Drupal\physicalCode
public function parse($number) {
if ($this->numberFormatter) {
$number = $this->numberFormatter
->parse($number);
// The returned number should be a string.
if (is_numeric($number)) {
$number = (string) $number;
}
}
elseif (!is_numeric($number)) {
// The intl extension is missing, validate the number at least.
$number = FALSE;
}
return $number;
}