Index

CronExp

MMO\core\helpers · 1 symbol · generated 30 Sep 2026

class

CronExp

CronExp.php:15

A parsed 5-field cron expression (minute hour dayOfMonth month dayOfWeek), used by Cron to schedule jobs. dayOfMonth/dayOfWeek default to '?' ("don't care" -- either one being '?' means only the other constrains the match; standard cron convention).

class MMO\core\helpers\CronExp implements Stringable
Namespace
MMO\core\helpers
Implements
Stringable
$exp = CronExp::From('@daily'); // '0 0 * * *' $exp->check(new DateTime('2024-01-01 00:00:00')); // true $exp->check(new DateTime('2024-01-01 00:01:00')); // false

Index

ALIAS staticNamed shorthand expressions recognized by From, e.g.
dayOfMonth
dayOfWeek
hour
minute
month
check($date)
describe()
From($value) staticParse a cron expression, either a raw 5-field string or a registered $ALIAS.
FromDate($date) staticBuild an expression that matches exactly one point in time (to the minute): $date's own minute/hour/day-of-month/month, with dayOfWeek left as '?'.
GetAlias($alias) static
isValid()
SetAlias($alias, $value) staticRegister (or, with $value null, remove) a named alias for From to recognize.
__construct($minute, $hour, $dayOfMonth, $month, $dayOfWeek)
__toString()

Properties6

ALIAS

static

Named shorthand expressions recognized by From, e.g. '@daily' => '0 0 * * *'.

static array $ALIAS = […7 items]
Type
array

dayOfMonth

string $dayOfMonth
Type
string

dayOfWeek

string $dayOfWeek
Type
string

minute

string $minute
Type
string

Methods9

describe()

CronExp.php:130
function describe(): string
returnsstringa human-readable description of the schedule (e.g. "every day at midnight")
throwsalways, until it is

From($value)

staticCronExp.php:61

Parse a cron expression, either a raw 5-field string or a registered $ALIAS.

static function From(string $value): static
$valuestringe.g. '0 0 * * *', or '@daily'
returnsstatic
throwsif $value starts with '@' but isn't a registered alias
CronExp::From('0 5 * * *');CronExp::From('@daily');

FromDate($date)

staticCronExp.php:78

Build an expression that matches exactly one point in time (to the minute): $date's own minute/hour/day-of-month/month, with dayOfWeek left as '?'.

static function FromDate(DateTimeInterface|string $date): static
CronExp::FromDate(new DateTime('2024-03-15 14:30:00')); // '30 14 15 03 *'

GetAlias($alias)

staticCronExp.php:49
static function GetAlias(string $alias): ?string
$aliasstring
returnsnull | stringthe alias's expansion, or null if $alias isn't registered

SetAlias($alias, $value)

staticCronExp.php:40

Register (or, with $value null, remove) a named alias for From to recognize.

static function SetAlias(string $alias, ?string $value): void
$aliasstringe.g. '@custom'
$valuenull | stringthe 5-field cron expression it expands to, or null to remove the alias
returnsvoid
CronExp::SetAlias('@custom', '0 5 * * *');

__construct($minute, $hour, $dayOfMonth, $month, $dayOfWeek)

CronExp.php:91
function __construct( string $minute = '*', string $hour = '*', string $dayOfMonth = '?', string $month = '*', string $dayOfWeek = '?' )
$minute = '*'string
$hour = '*'string
$dayOfMonth = '?'string
$month = '*'string
$dayOfWeek = '?'string

__toString()

CronExp.php:100
function __toString(): string
returnsstringthe raw 5-field expression, e.g. '0 0 * * *'