src/TaskRunner.php
public static function checkAndRunTasks($tasks)
    {
        $date = date('Y-m-d H:i:s');
        foreach ($tasks as $t) {
            /**
             * @var TaskInterface $t
             */
            if (TaskInterface::TASK_STATUS_ACTIVE != $t->getStatus()) {
                continue;
            }

            try {
                $cron = CronExpression::factory($t->getTime());

                if ($cron->isDue($date)) {
                    self::runTask($t);
                }
            } catch (\Exception $e) {
                echo 'Caught an exception: ' . get_class($e) . ': ' . PHP_EOL . $e->getMessage() . PHP_EOL;
            }
        }
    }
public static function checkAndRunTasks($tasks)
    {
        $date = date('Y-m-d H:i:s');
        foreach ($tasks as $t) {
            /**
             * @var TaskInterface $t
             */
            if (TaskInterface::TASK_STATUS_ACTIVE != $t->getStatus()) {
                continue;
            }

            try {
                $cron = CronExpression::factory($t->getTime());

                if ($cron->isDue($date)) {
                    self::runTask($t);
                }
            } catch (\Exception $e) {
                echo 'Caught an exception: ' . get_class($e) . ': ' . PHP_EOL . $e->getMessage() . PHP_EOL;
            }
        }
    }
public static function checkAndRunTasks ( $ tasks ) { $ date = date ( 'Y-m-d H:i:s' ) ; foreach ( $ tasks as $ t ) { /**
             * @var TaskInterface $t
             */ if ( TaskInterface :: TASK_STATUS_ACTIVE != $ t -> getStatus ( ) ) { continue ; } try { $ cron = CronExpression :: factory ( $ t -> getTime ( ) ) ; if ( $ cron -> isDue ( $ date ) ) { self :: runTask ( $ t ) ; } } catch ( \ Exception $ e ) { echo 'Caught an exception: ' . get_class ( $ e ) . ': ' . PHP_EOL . $ e -> getMessage ( ) . PHP_EOL ; } } }
Runs active tasks if current time matches with time expression
@param array $tasks
Runs active tasks if current time matches with time expression