You are here

function CronRule::expandInterval in Ultimate Cron 8

Same name and namespace in other branches
  1. 6 CronRule.class.php \CronRule::expandInterval()
  2. 7.2 CronRule.class.php \CronRule::expandInterval()
  3. 7 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 43
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 = $matches[2];
  $step = isset($matches[5]) ? $matches[5] : 1;
  $offset = isset($matches[7]) ? $matches[7] : 0;
  if ($step <= 0) {
    return '';
  }
  $step = $step > 0 ? $step : 1;
  for ($i = $lower; $i <= $upper; $i += $step) {
    $result[] = ($i + $offset) % ($upper + 1);
  }
  return implode(',', $result);
}