private static function relativeCmp($left, $right, $cmp)
{
if (!(is_int($left) || is_float($left)) || !(is_int($right) || is_float($right))) {
return false;
}
switch ($cmp) {
case '>':
return $left > $right;
case '>=':
return $left >= $right;
case '<':
return $left < $right;
case '<=':
return $left <= $right;
default:
throw new \RuntimeException("Invalid comparison: {$cmp}");
}
}