Plural form is one of following: zero, one, two, few, many, other.
Last one (other) is returned when number provided doesn't match any
of the rules, or there is no rules for given locale.
public getPluralForm ( mixed $quantity, |
||
$quantity | mixed | A number to find plural form for (float or int) |
$locale | ||
return | string | One of plural form constants |
/** * Get the plural form to be used. * * If $quantity is numeric and non-NULL, the plural form for provided $locale will be * chosen according to it. * * In all other cases, NULL is returned. * * @param mixed $quantity * @param Locale $locale * @return string */ protected function getPluralForm($quantity, Locale $locale) { if (!is_numeric($quantity)) { return null; } else { return $this->pluralsReader->getPluralForm($quantity, $locale); } }
/** * @test * @dataProvider quantities */ public function returnsCorrectPluralForm($quantity, $pluralForm) { $locale = new I18n\Locale('mo'); $result = $this->reader->getPluralForm($quantity, $locale); $this->assertEquals($pluralForm, $result); }