protected function parseRule($rule)
{
$parsedRule = [];
if (preg_match_all(self::PATTERN_MATCH_SUBRULE, strtolower(str_replace(' ', '', $rule)), $matches, \PREG_SET_ORDER)) {
foreach ($matches as $matchedSubrule) {
$subrule = [];
if ($matchedSubrule[1] === 'nmod') {
$subrule['modulo'] = (int) $matchedSubrule[2];
} else {
$subrule['modulo'] = false;
}
$condition = [$matchedSubrule[3], (int) $matchedSubrule[4]];
if (!in_array($matchedSubrule[3], ['is', 'isnot'], true)) {
$condition[2] = (int) $matchedSubrule[5];
}
$subrule['condition'] = $condition;
if (isset($matchedSubrule[6]) && ($matchedSubrule[6] === 'and' || $matchedSubrule[6] === 'or')) {
$subrule['logicalOperator'] = $matchedSubrule[6];
} else {
$subrule['logicalOperator'] = false;
}
$parsedRule[] = $subrule;
}
} else {
throw new Exception\InvalidPluralRuleException('A plural rule string is invalid. CLDR files might be corrupted.', 1275493982);
}
return $parsedRule;
}