protected function extractRangeRule(Rules $rules)
{
$controlMin = $controlMax = null;
foreach ($rules as $rule) {
$branch = property_exists($rule, 'branch') ? $rule->branch : $rule->subRules;
if (!$branch) {
$validator = property_exists($rule, 'validator') ? $rule->validator : $rule->operation;
if ($validator === Form::RANGE && !$rule->isNegative) {
$ruleMinMax = $rule->arg;
}
} elseif ($branch) {
$validator = property_exists($rule, 'validator') ? $rule->validator : $rule->operation;
if ($validator === Form::FILLED && !$rule->isNegative && $rule->control === $this) {
$ruleMinMax = $this->extractRangeRule($branch);
}
}
if (isset($ruleMinMax)) {
list($ruleMin, $ruleMax) = $ruleMinMax;
if ($ruleMin !== null && ($controlMin === null || $ruleMin > $controlMin)) {
$controlMin = $ruleMin;
}
if ($ruleMax !== null && ($controlMax === null || $ruleMax < $controlMax)) {
$controlMax = $ruleMax;
}
$ruleMinMax = null;
}
}
return array($controlMin, $controlMax);
}