TaskDefinition
A named unit of scheduled work: a human-readable `$name`, the cron expression that gates when it runs, and the `$callback` a runner ({@see CronRunner}, Task 10) invokes when it's due. Hosts and plugins ({@see CronProviderInterface}) construct these; this package never runs the callback itself — {@see self::isDue()} only answers "should this run now?".
TaskDefinition::__construct()
public function __construct(string $name, string $expression, Closure $callback, string $description = ''):Parameters
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $expression | string | |
| $callback | Closure | |
| $description | string |
Throws
\InvalidArgumentException if `$expression` is not a valid 5-field cron
expression — see {@see CronExpression::__construct()}.
TaskDefinition::expression()
public function expression(): stringThe raw cron expression string this task was defined with, e.g. `0 3 * * *`. Callers that render a task list (Task 11's `cron:list`) use this alongside `$name`.
TaskDefinition::isDue()
public function isDue(DateTimeImmutable $now): boolTrue when `$now` matches this task's cron expression. Delegates entirely to {@see CronExpression::isDue()} — this method exists so callers ({@see CronRegistry}) work against `TaskDefinition` without reaching into its expression.
Parameters
| Name | Type | Description |
|---|---|---|
| $now | DateTimeImmutable |