Cron
in package
Cron class
Tags
Table of Contents
Properties
- $daysOfTheMonth : array<string|int, mixed>
- Days of the month
- $daysOfTheWeek : array<string|int, mixed>
- Days of the week
- $gracePeriod : int
- Grace period, in seconds, allowed between the scheduled time and the evaluation of it. Defaults to -1, i.e. the seconds value is disregarded and the schedule is due for the whole of its matching minute.
- $hours : array<string|int, mixed>
- Hours
- $minutes : array<string|int, mixed>
- Minutes
- $months : array<string|int, mixed>
- Months
- $schedule : string|null
- Schedule string
- $seconds : array<string|int, mixed>
- Seconds - Not a standard cron unit of time. The smallest time interval supported by cron is 1 minute.
Methods
- __construct() : mixed
- Constructor
- __toString() : string
- To string method
- between() : Cron
- Set job schedule to between two hours
- create() : Cron
- Factory
- daily() : Cron
- Set job schedule to daily (alias to hours)
- dailyAt() : Cron
- Set job schedule to daily at specific time, i.e. 14:30
- evaluate() : bool
- Evaluate the set cron schedule value against a time value
- every10Minutes() : Cron
- Set job schedule to every 10 minutes
- every10Seconds() : Cron
- Set job schedule to every 10 seconds
- every15Minutes() : Cron
- Set job schedule to every 15 minutes
- every15Seconds() : Cron
- Set job schedule to every 15 seconds
- every20Minutes() : Cron
- Set job schedule to every 20 minutes
- every20Seconds() : Cron
- Set job schedule to every 20 seconds
- every30Minutes() : Cron
- Set job schedule to every 30 minutes
- every30Seconds() : Cron
- Set job schedule to every 30 seconds
- every5Minutes() : Cron
- Set job schedule to every 5 minutes
- every5Seconds() : Cron
- Set job schedule to every 5 seconds
- everyMinute() : Cron
- Set job schedule to every minute
- everySecond() : Cron
- Set job schedule to every second
- fridays() : Cron
- Set job schedule to Fridays
- getDaysOfTheMonth() : array<string|int, mixed>
- Get days of the month
- getDaysOfTheWeek() : array<string|int, mixed>
- Get days of the week
- getGracePeriod() : int
- Get grace period
- getHours() : array<string|int, mixed>
- Get hours
- getMinutes() : array<string|int, mixed>
- Get minutes
- getMonths() : array<string|int, mixed>
- Get months
- getSchedule() : string|null
- Get schedule string
- getSeconds() : array<string|int, mixed>
- Get seconds
- hasGracePeriod() : bool
- Has grace period
- hasSchedule() : bool
- Has schedule string
- hasSeconds() : bool
- Has seconds
- hourly() : Cron
- Set job schedule to hourly
- hours() : Cron
- Set job schedule to by specific hours
- minutes() : Cron
- Set job schedule to by specific minutes
- mondays() : Cron
- Set job schedule to Mondays
- monthly() : Cron
- Set job schedule to monthly
- quarterly() : Cron
- Set job schedule to quarterly
- render() : string
- Render the cron schedule string
- saturdays() : Cron
- Set job schedule to Saturdays
- schedule() : Cron
- Set cron schedule
- seconds() : Cron
- Set job schedule to by specific seconds
- setGracePeriod() : Cron
- Set grace period
- sundays() : Cron
- Set job schedule to Sundays
- thursdays() : Cron
- Set job schedule to Thursdays
- tuesdays() : Cron
- Set job schedule to Tuesdays
- updateSchedule() : Cron
- Update cron schedule
- wednesdays() : Cron
- Set job schedule to Wednesdays
- weekdays() : Cron
- Set job schedule to weekdays
- weekends() : Cron
- Set job schedule to weekends
- weekly() : Cron
- Set job schedule to weekly
- yearly() : Cron
- Set job schedule to yearly
- evaluateExpression() : bool
- Determine if the value satisfies the schedule expression
- fieldPasses() : bool
- Determine whether one schedule field matches the corresponding value from the time being evaluated.
Properties
$daysOfTheMonth
Days of the month
protected
array<string|int, mixed>
$daysOfTheMonth
= []
$daysOfTheWeek
Days of the week
protected
array<string|int, mixed>
$daysOfTheWeek
= []
$gracePeriod
Grace period, in seconds, allowed between the scheduled time and the evaluation of it. Defaults to -1, i.e. the seconds value is disregarded and the schedule is due for the whole of its matching minute.
protected
int
$gracePeriod
= -1
$hours
Hours
protected
array<string|int, mixed>
$hours
= []
$minutes
Minutes
protected
array<string|int, mixed>
$minutes
= []
$months
Months
protected
array<string|int, mixed>
$months
= []
$schedule
Schedule string
protected
string|null
$schedule
= null
$seconds
Seconds - Not a standard cron unit of time. The smallest time interval supported by cron is 1 minute.
protected
array<string|int, mixed>
$seconds
= []
This is to support time intervals less than minute and down to 1 second.
Methods
__construct()
Constructor
public
__construct([string|null $schedule = null ][, int $gracePeriod = -1 ]) : mixed
Instantiate the cron object
Parameters
- $schedule : string|null = null
- $gracePeriod : int = -1
__toString()
To string method
public
__toString() : string
Return values
stringbetween()
Set job schedule to between two hours
public
between(int $start, int $end) : Cron
Parameters
- $start : int
- $end : int
Return values
Croncreate()
Factory
public
static create([string|null $schedule = null ]) : Cron
Parameters
- $schedule : string|null = null
Return values
Crondaily()
Set job schedule to daily (alias to hours)
public
daily(mixed $hours[, mixed $minutes = null ]) : Cron
Parameters
- $hours : mixed
- $minutes : mixed = null
Return values
CrondailyAt()
Set job schedule to daily at specific time, i.e. 14:30
public
dailyAt(string $time) : Cron
Parameters
- $time : string
Return values
Cronevaluate()
Evaluate the set cron schedule value against a time value
public
evaluate([mixed $time = null ][, int|null $gracePeriod = null ]) : bool
The grace period governs how late an evaluation may be and still count as due. It applies only to minute-granularity schedules; a schedule with a seconds field is always evaluated exactly.
$gracePeriod = -1; disregards the seconds value - due for the whole of the matching minute (the default) $gracePeriod = 1-59; due within that many seconds of the scheduled time $gracePeriod = 0; strict evaluation to the 00 second
Note that a missed window is not made up later - there is no catch-up.
Parameters
- $time : mixed = null
- $gracePeriod : int|null = null
Tags
Return values
boolevery10Minutes()
Set job schedule to every 10 minutes
public
every10Minutes() : Cron
Return values
Cronevery10Seconds()
Set job schedule to every 10 seconds
public
every10Seconds() : Cron
Return values
Cronevery15Minutes()
Set job schedule to every 15 minutes
public
every15Minutes() : Cron
Return values
Cronevery15Seconds()
Set job schedule to every 15 seconds
public
every15Seconds() : Cron
Return values
Cronevery20Minutes()
Set job schedule to every 20 minutes
public
every20Minutes() : Cron
Return values
Cronevery20Seconds()
Set job schedule to every 20 seconds
public
every20Seconds() : Cron
Return values
Cronevery30Minutes()
Set job schedule to every 30 minutes
public
every30Minutes() : Cron
Return values
Cronevery30Seconds()
Set job schedule to every 30 seconds
public
every30Seconds() : Cron
Return values
Cronevery5Minutes()
Set job schedule to every 5 minutes
public
every5Minutes() : Cron
Return values
Cronevery5Seconds()
Set job schedule to every 5 seconds
public
every5Seconds() : Cron
Return values
CroneveryMinute()
Set job schedule to every minute
public
everyMinute() : Cron
Return values
CroneverySecond()
Set job schedule to every second
public
everySecond() : Cron
Return values
Cronfridays()
Set job schedule to Fridays
public
fridays() : Cron
Return values
CrongetDaysOfTheMonth()
Get days of the month
public
getDaysOfTheMonth() : array<string|int, mixed>
Return values
array<string|int, mixed>getDaysOfTheWeek()
Get days of the week
public
getDaysOfTheWeek() : array<string|int, mixed>
Return values
array<string|int, mixed>getGracePeriod()
Get grace period
public
getGracePeriod() : int
Return values
intgetHours()
Get hours
public
getHours() : array<string|int, mixed>
Return values
array<string|int, mixed>getMinutes()
Get minutes
public
getMinutes() : array<string|int, mixed>
Return values
array<string|int, mixed>getMonths()
Get months
public
getMonths() : array<string|int, mixed>
Return values
array<string|int, mixed>getSchedule()
Get schedule string
public
getSchedule() : string|null
Return values
string|nullgetSeconds()
Get seconds
public
getSeconds() : array<string|int, mixed>
Return values
array<string|int, mixed>hasGracePeriod()
Has grace period
public
hasGracePeriod() : bool
Only a grace period of exactly 0 - strict evaluation to the 00 second - grants no grace. A negative value is the loosest setting there is, not the absence of one.
Return values
boolhasSchedule()
Has schedule string
public
hasSchedule() : bool
Return values
boolhasSeconds()
Has seconds
public
hasSeconds() : bool
Return values
boolhourly()
Set job schedule to hourly
public
hourly([mixed $minutes = null ]) : Cron
Parameters
- $minutes : mixed = null
Return values
Cronhours()
Set job schedule to by specific hours
public
hours(mixed $hours[, mixed $minutes = null ]) : Cron
Parameters
- $hours : mixed
- $minutes : mixed = null
Return values
Cronminutes()
Set job schedule to by specific minutes
public
minutes(mixed $minutes) : Cron
Parameters
- $minutes : mixed
Return values
Cronmondays()
Set job schedule to Mondays
public
mondays() : Cron
Return values
Cronmonthly()
Set job schedule to monthly
public
monthly(mixed $day[, mixed $hours = null ][, mixed $minutes = null ]) : Cron
Parameters
- $day : mixed
- $hours : mixed = null
- $minutes : mixed = null
Return values
Cronquarterly()
Set job schedule to quarterly
public
quarterly([mixed $hours = null ][, mixed $minutes = null ]) : Cron
Parameters
- $hours : mixed = null
- $minutes : mixed = null
Return values
Cronrender()
Render the cron schedule string
public
render() : string
Return values
stringsaturdays()
Set job schedule to Saturdays
public
saturdays() : Cron
Return values
Cronschedule()
Set cron schedule
public
schedule(string $schedule) : Cron
min hour dom month dow
- OR non-standard -
sec min hour dom month dow
Parameters
- $schedule : string
Return values
Cronseconds()
Set job schedule to by specific seconds
public
seconds(mixed $seconds) : Cron
Parameters
- $seconds : mixed
Return values
CronsetGracePeriod()
Set grace period
public
setGracePeriod(int $gracePeriod) : Cron
Parameters
- $gracePeriod : int
Return values
Cronsundays()
Set job schedule to Sundays
public
sundays() : Cron
Return values
Cronthursdays()
Set job schedule to Thursdays
public
thursdays() : Cron
Return values
Crontuesdays()
Set job schedule to Tuesdays
public
tuesdays() : Cron
Return values
CronupdateSchedule()
Update cron schedule
public
updateSchedule() : Cron
Return values
Cronwednesdays()
Set job schedule to Wednesdays
public
wednesdays() : Cron
Return values
Cronweekdays()
Set job schedule to weekdays
public
weekdays() : Cron
Return values
Cronweekends()
Set job schedule to weekends
public
weekends() : Cron
Return values
Cronweekly()
Set job schedule to weekly
public
weekly(mixed $day[, mixed $hours = null ][, mixed $minutes = null ]) : Cron
Parameters
- $day : mixed
- $hours : mixed = null
- $minutes : mixed = null
Return values
Cronyearly()
Set job schedule to yearly
public
yearly([bool $endOfYear = false ][, mixed $hours = null ][, mixed $minutes = null ]) : Cron
Parameters
- $endOfYear : bool = false
- $hours : mixed = null
- $minutes : mixed = null
Return values
CronevaluateExpression()
Determine if the value satisfies the schedule expression
protected
evaluateExpression(string $expression, mixed $value) : bool
Parameters
- $expression : string
- $value : mixed
Return values
boolfieldPasses()
Determine whether one schedule field matches the corresponding value from the time being evaluated.
protected
fieldPasses(array<string|int, mixed> $field, int $value) : bool
This is the per-field test that evaluate() used to inline six times over. The three cases, in the order the original checked them: the wildcard '*', a literal value present in the field, and - only for a single-element string field - a compound expression (a comma list, a step, or a range) handed off to evaluateExpression().
The loose in_array() comparison is intentional and load-bearing: field values arrive as strings when parsed out of a schedule string but as ints when set through the fluent helpers (hourly(), daily(), and friends all assign ints), so both have to compare equal to the int taken from the timestamp.
Parameters
- $field : array<string|int, mixed>
- $value : int