You are here

protected function GeneralNumberFormatter::selectSuffix in Formatter Suite 8

Returns a suffix selected based on the value.

If there are less than 2 suffixes, the first one is always returned. Otherwise the singular or plural suffix is returned based upon the given value.

Parameters

mixed $number: The number to check for singular vs. plural.

array $suffixes: An array of 1 or 2 strings for singular and plural prefixes.

Return value

string Returns the chosen singular or plural suffix.

5 calls to GeneralNumberFormatter::selectSuffix()
GeneralNumberFormatter::numberFormatBasic in src/Plugin/Field/FieldFormatter/GeneralNumberFormatter.php
Formats a number using the basic set of formatting features.
GeneralNumberFormatter::numberFormatGeneral in src/Plugin/Field/FieldFormatter/GeneralNumberFormatter.php
Formats a number using the general set of formatting features.
GeneralNumberFormatter::numberFormatNumeral in src/Plugin/Field/FieldFormatter/GeneralNumberFormatter.php
Formats a number using a number system base.
GeneralNumberFormatter::numberFormatScientific in src/Plugin/Field/FieldFormatter/GeneralNumberFormatter.php
Formats a number using scientific notation.
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 1000

Class

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

Namespace

Drupal\formatter_suite\Plugin\Field\FieldFormatter

Code

protected function selectSuffix($number, array $suffixes) {
  if (count($suffixes) === 1) {
    return $suffixes[0];
  }
  return $this
    ->formatPlural($number, $suffixes[0], $suffixes[1]);
}