You are here

protected function GeneralNumberFormatter::numberFormatPercentage in Formatter Suite 8

Formats a number using a basic set of formatting features for percentages.

This is the same as basic notation except:

  • The value is multiplied by 100 before formatting.
  • A '%' is always added as a suffix.

Parameters

mixed $number: The number to format.

Return value

string The formatted number, including the prefix or suffix.

1 call to GeneralNumberFormatter::numberFormatPercentage()
GeneralNumberFormatter::numberFormat in src/Plugin/Field/FieldFormatter/GeneralNumberFormatter.php
Format a number using the current settings.

File

src/Plugin/Field/FieldFormatter/GeneralNumberFormatter.php, line 1333

Class

GeneralNumberFormatter
Format a number field with a variety of notation styles and parameters.

Namespace

Drupal\formatter_suite\Plugin\Field\FieldFormatter

Code

protected function numberFormatPercentage($number) {
  if (is_int($number) === TRUE) {
    return $this
      ->numberFormatBasic($number * 100, '%');
  }
  return $this
    ->numberFormatBasic($number * 100.0, '%');
}