protected function GeneralNumberFormatter::numberFormat in Formatter Suite 8
Format a number using the current settings.
Parameters
mixed $number: The number to format.
Return value
string The formatted number, not including the prefix or suffix.
3 calls to GeneralNumberFormatter::numberFormat()
- GeneralNumberFormatter::settingsSummary in src/
Plugin/ Field/ FieldFormatter/ GeneralNumberFormatter.php - Returns a short summary for the current formatter settings.
- GeneralNumberFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ GeneralNumberFormatter.php - Builds a renderable array for a field value.
- GeneralNumberWithMinMaxFormatter::numberFormat in src/
Plugin/ Field/ FieldFormatter/ GeneralNumberWithMinMaxFormatter.php - Returns a formatted number, including min, max, prefix, and suffix.
1 method overrides GeneralNumberFormatter::numberFormat()
- GeneralNumberWithMinMaxFormatter::numberFormat in src/
Plugin/ Field/ FieldFormatter/ GeneralNumberWithMinMaxFormatter.php - Returns a formatted number, including min, max, prefix, and suffix.
File
- src/
Plugin/ Field/ FieldFormatter/ GeneralNumberFormatter.php, line 1017
Class
- GeneralNumberFormatter
- Format a number field with a variety of notation styles and parameters.
Namespace
Drupal\formatter_suite\Plugin\Field\FieldFormatterCode
protected function numberFormat($number) {
// Sanitize and get current settings.
$this
->sanitizeSettings();
// Format scientific notation separately.
switch ($this
->getSetting('notationStyle')) {
default:
case 'basicnumber':
return $this
->numberFormatBasic($number, '');
case 'generalnumber':
return $this
->numberFormatGeneral($number);
case 'numeralsystem':
return $this
->numberFormatNumeral($number);
case 'percentage':
return $this
->numberFormatPercentage($number);
case 'scientific':
return $this
->numberFormatScientific($number);
}
}