| @@ 40-67 (lines=28) @@ | ||
| 37 | * @return array Next run timestamp at first position, expression parts at second |
|
| 38 | * @throws \Exception |
|
| 39 | */ |
|
| 40 | public static function cronExpression($expression) { |
|
| 41 | ||
| 42 | try { |
|
| 43 | ||
| 44 | $cron = CronExpression::factory($expression); |
|
| 45 | ||
| 46 | $s = $cron->getNextRunDate()->format('c'); |
|
| 47 | ||
| 48 | $e = $cron->getExpression(); |
|
| 49 | ||
| 50 | $e_array = preg_split('/\s/', $e, -1, PREG_SPLIT_NO_EMPTY); |
|
| 51 | ||
| 52 | $e_count = count($e_array); |
|
| 53 | ||
| 54 | if ( $e_count < 5 || $e_count > 6 ) throw new Exception($e." is not a valid cron expression"); |
|
| 55 | ||
| 56 | if ( $e_count == 5 ) $e_array[] = "*"; |
|
| 57 | ||
| 58 | } |
|
| 59 | catch (Exception $e) { |
|
| 60 | ||
| 61 | throw $e; |
|
| 62 | ||
| 63 | } |
|
| 64 | ||
| 65 | return array($s, $e_array); |
|
| 66 | ||
| 67 | } |
|
| 68 | ||
| 69 | public static function laggerTimeout($timeout) { |
|
| 70 | ||
| @@ 459-486 (lines=28) @@ | ||
| 456 | * @return array Next run timestamp at first position, expression parts at second |
|
| 457 | * @throws \Exception |
|
| 458 | */ |
|
| 459 | final public static function validateExpression($expression) { |
|
| 460 | ||
| 461 | try { |
|
| 462 | ||
| 463 | $cron = CronExpression::factory($expression); |
|
| 464 | ||
| 465 | $s = $cron->getNextRunDate()->format('c'); |
|
| 466 | ||
| 467 | $e = $cron->getExpression(); |
|
| 468 | ||
| 469 | $e_array = preg_split('/\s/', $e, -1, PREG_SPLIT_NO_EMPTY); |
|
| 470 | ||
| 471 | $e_count = count($e_array); |
|
| 472 | ||
| 473 | if ( $e_count < 5 || $e_count > 6 ) throw new Exception($e." is not a valid cron expression"); |
|
| 474 | ||
| 475 | if ( $e_count == 5 ) $e_array[] = "*"; |
|
| 476 | ||
| 477 | } |
|
| 478 | catch (Exception $e) { |
|
| 479 | ||
| 480 | throw $e; |
|
| 481 | ||
| 482 | } |
|
| 483 | ||
| 484 | return array($s, $e_array); |
|
| 485 | ||
| 486 | } |
|
| 487 | ||
| 488 | /** |
|
| 489 | * Get planned jobs |
|