You are here

function _cronDecodeRule in Elysia Cron 5.2

Same name and namespace in other branches
  1. 5 elysia_cron_scheduler_old.inc \_cronDecodeRule()
  2. 6.2 elysia_cron_scheduler_old.inc \_cronDecodeRule()
  3. 6 elysia_cron_scheduler_old.inc \_cronDecodeRule()
  4. 7.2 elysia_cron_scheduler.inc \_cronDecodeRule()
  5. 7 elysia_cron_scheduler_old.inc \_cronDecodeRule()
1 call to _cronDecodeRule()
elysia_cron_should_run in ./elysia_cron_scheduler_old.inc

File

./elysia_cron_scheduler_old.inc, line 132

Code

function _cronDecodeRule($rule, $min, $max) {
  if ($rule == '*') {
    return range($min, $max);
  }
  $result = array();
  foreach (explode(',', $rule) as $token) {
    if (preg_match('/^([0-9]+)-([0-9]+)$/', $token, $r)) {
      $result = array_merge($result, range($r[1], $r[2]));
    }
    elseif (preg_match('/^\\*\\/([0-9]+)$/', $token, $r)) {
      for ($i = $min; $i <= $max; $i++) {
        if ($i % $r[1] == 0) {
          $result[] = $i;
        }
      }
    }
    elseif (is_numeric($token)) {
      $result[] = $token;
    }
  }
  return $result;
}