/** * Given an array of strings, a number and, if wanted, an optional locale (the default one is used * otherwise), this picks the right string according to plural rules of the locale * * @param array|string $strings * @param int $number * @throws Exception\InvalidArgumentException * @return string */ public function __invoke($strings, $number) { if ($this->rule === null) { throw new Exception\InvalidArgumentException(sprintf('No plural rule was set')); } if (!is_array($strings)) { $strings = (array) $strings; } $pluralIndex = $this->rule->evaluate($number); return $strings[$pluralIndex]; }