Skip to content

Commit

Permalink
Update interval_range_utils.php
Browse files Browse the repository at this point in the history
  • Loading branch information
cowpod committed Oct 13, 2024
1 parent 6f691a9 commit f7098c7
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion functions/interval_range_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,49 @@ function in_range($range, $num) {
$matches=[];
if (preg_match("/^(\[)([0-9\.]*),\s?([0-9\.]*)(\])$/", $range, $matches)) { // [, ]
[$full,$not1,$low,$high,$not2]=$matches;
if (empty($high)) {
return (version_compare($num, $low, '>='));
}
if (empty($low)) {
return (version_compare($num, $high, '<='));
}
return (version_compare($num, $low, '>=') && version_compare($num, $high, '<='));
}
elseif (preg_match("/^(\[)([0-9\.]*),\s?([0-9\.]*)(\))$/", $range, $matches)) { // [, )
[$full,$not1,$low,$high,$not2]=$matches;
if (empty($high)) {
return (version_compare($num, $low, '>='));
}
if (empty($low)) {
return (version_compare($num, $high, '<'));
}
return (version_compare($num, $low, '>=') && version_compare($num, $high, '<'));
}
elseif (preg_match("/^(\()([0-9\.]*),\s?([0-9\.]*)(\])$/", $range, $matches)) { // (, ]
[$full,$not1,$low,$high,$not2]=$matches;
if (empty($high)) {
return (version_compare($num, $low, '>'));
}
if (empty($low)) {
return (version_compare($num, $high, '<='));
}
return (version_compare($num, $low, '>') && version_compare($num, $high, '<='));
}
elseif (preg_match("/^(\()([0-9\.]*),\s?([0-9\.]*)(\))$/", $range, $matches)) { // (, )
[$full,$not1,$low,$high,$not2]=$matches;
if (empty($high)) {
return (version_compare($num, $low, '>'));
}
if (empty($low)) {
return (version_compare($num, $high, '<'));
}
return (version_compare($num, $low, '>') && version_compare($num, $high, '<'));
}

// assume range is just a string?
return version_compare($range,$num,'=');
}


function parse_interval_range($mcversion) {
$min=null;
$max=null;
Expand Down

0 comments on commit f7098c7

Please sign in to comment.