MediaWiki  REL1_20
CLDRPluralRuleEvaluator Class Reference

List of all members.

Static Public Member Functions

static compile (array $rules)
 Convert a set of rules to a compiled form which is optimised for fast evaluation.
static evaluate ($number, array $rules)
 Evaluate a number against a set of plural rules.
static evaluateCompiled ($number, array $rules)
 Evaluate a compiled set of rules returned by compile().

Static Private Member Functions

static doOperation ($token, $left, $right)
 Do a single operation.

Detailed Description

Definition at line 15 of file CLDRPluralRuleEvaluator.php.


Member Function Documentation

static CLDRPluralRuleEvaluator::compile ( array $  rules) [static]

Convert a set of rules to a compiled form which is optimised for fast evaluation.

The result will be an array of strings, and may be cached.

Parameters:
$rulesThe rules to compile
Returns:
An array of compile rules.

Definition at line 36 of file CLDRPluralRuleEvaluator.php.

References CLDRPluralRuleConverter\convert().

Referenced by evaluate().

static CLDRPluralRuleEvaluator::doOperation ( token,
left,
right 
) [static, private]

Do a single operation.

Parameters:
$tokenstring The token string
$leftThe left operand. If it is an object, its state may be destroyed.
$rightThe right operand
Returns:
mixed

Definition at line 86 of file CLDRPluralRuleEvaluator.php.

Referenced by evaluateCompiled().

static CLDRPluralRuleEvaluator::evaluate ( number,
array $  rules 
) [static]

Evaluate a number against a set of plural rules.

If a rule passes, return the index of plural rule.

Parameters:
intThe number to be evaluated against the rules
arrayThe associative array of plural rules in pluralform => rule format.
Returns:
int The index of the plural form which passed the evaluation

Definition at line 24 of file CLDRPluralRuleEvaluator.php.

References compile(), and evaluateCompiled().

Referenced by CLDRPluralRuleEvaluatorTest\testInvalidRules(), and CLDRPluralRuleEvaluatorTest\testValidRules().

static CLDRPluralRuleEvaluator::evaluateCompiled ( number,
array $  rules 
) [static]

Evaluate a compiled set of rules returned by compile().

Do not allow the user to edit the compiled form, or else PHP errors may result.

Definition at line 49 of file CLDRPluralRuleEvaluator.php.

References $result, doOperation(), and StringUtils\explode().

Referenced by evaluate().


The documentation for this class was generated from the following file: