This component is designed for development workflows that would benefit from having scheduled tasks defined in PHP or at least in the same codebase as the rest of the code.

Cron Jobs are represented by Centum\Cron\Job. Jobs take two parameters, the Cron expression and the job data which can take any form:

use Centum\Cron\Job;

$job1 = new Job(
    "* * * * *",

$job2 = new Job(
    "echo 'hello world'"

$job3 = new Job(
    "0 9 * * 1-5",
    function (): void {
        // Do something...

Cron Jobs can be added to a Centum\Cron\Cron object that determines which jobs are due at any given time.

Centum\Cron\Cron implements Centum\Interfaces\Cron\CronInterface.

use Centum\Cron\Cron;

$cron = new Cron();


$dueJobs = $cron->getDueJobs();

foreach ($dueJobs as $job) {
    $data = $job->getData();

    // Do something...

Table of contents