function CronRule::expandInterval in Ultimate Cron 7
Same name and namespace in other branches
- 8 CronRule.class.php \CronRule::expandInterval()
- 6 CronRule.class.php \CronRule::expandInterval()
- 7.2 CronRule.class.php \CronRule::expandInterval()
Expand interval from cronrule part
Parameters
$matches (e.g. 4-43/5+2): array of matches: [1] = lower [2] = upper [5] = step [7] = offset
Return value
(string) comma-separated list of values
File
- ./
CronRule.class.php, line 44 - This class parses cron rules and determines last execution time using least case integer comparison.
Class
- CronRule
- @file
Code
function expandInterval($matches) {
$result = array();
$lower = $matches[1];
$upper = isset($matches[2]) && $matches[2] != '' ? $matches[2] : $lower;
$step = isset($matches[5]) && $matches[5] != '' ? $matches[5] : 1;
$offset = isset($matches[7]) && $matches[7] != '' ? $matches[7] : 0;
if ($step <= 0) {
return '';
}
$step = $step > 0 ? $step : 1;
for ($i = $lower; $i <= $upper; $i += $step) {
$result[] = ($i + $offset) % (self::$ranges[$this->type][1] + 1);
}
return implode(',', $result);
}