Plural rule evaluator.

 Methods

Evaluate a number and return the plural index.

evaluate(int $number) : int

Parameters

$number

int

Exceptions

\Zend\I18n\Exception\RangeException

Returns

int

Create a new rule from a string.

fromString(string $string) : \Zend\I18n\Translator\Plural\Rule

Parameters

$string

string

Exceptions

\Zend\I18n\Exception\ParseException

Returns

Get number of possible plural forms.

getNumPlurals() : int

Returns

int

Create a new plural rule.

__construct(int $numPlurals, array $ast) : \Zend\I18n\Translator\Plural\Rule

Parameters

$numPlurals

int

$ast

array

Returns

Create an AST from a tree.

createAst(\Zend\I18n\Translator\Plural\Symbol $symbol) : array

Theoretically we could just use the given Symbol, but that one is not so easy to serialize and also takes up more memory.

Parameters

Returns

array

Evaluate a part of an ast.

evaluateAstPart(array $ast, int $number) : int

Parameters

$ast

array

$number

int

Exceptions

\Zend\I18n\Exception\ParseException

Returns

int

 Properties

 

Abstract syntax tree.

$ast : array

 

Number of plurals in this rule.

$numPlurals : int

 

Parser instance.

$parser : \Zend\I18n\Translator\Plural\Parser