NormalizeCommand
Validate and normalize a cron command.
Special fields like three letter weekdays, ranges and steps are substituted to a comma separated list of integers. Example: '2-4 10-40/10 * mar * fri' will be normalized to '2,4 10,20,30,40 * * 3 1,2'
not part of TYPO3 Public API
Table of Contents
Methods
- normalize() : string
- Main API method: Get the cron command and normalize it.
- convertKeywordsToCronCommand() : string
- Accept special cron command keywords and convert to standard cron syntax.
- convertRangeToListOfValues() : string
- Convert a range of integers to a list: 4-6 results in a string '4,5,6'
- normalizeFields() : string
- Normalize cron command field to list of integers or *
- normalizeIntegerField() : string
- Normalize integer field.
- normalizeMonth() : int
- Accept a string representation or integer number of a month like 'jan', 'February', 01, ... and convert to normalized integer value between 1 and 12
- normalizeMonthAndWeekday() : string
- Dispatcher method for normalizeMonth and normalizeWeekday
- normalizeMonthAndWeekdayField() : string
- Normalize month field.
- normalizeWeekday() : int
- Accept a string representation or integer number of a weekday like 'mon', 'Friday', 3, ... and convert to normalized integer value between 1 and 7
- reduceListOfValuesByStepValue() : string
- Reduce a given list of values by step value.
- splitFields() : array<string|int, mixed>
- Split a given cron command like '23 * * * *' to an array with five fields.
Methods
normalize()
Main API method: Get the cron command and normalize it.
public
static normalize(string $cronCommand) : string
If no exception is thrown, the resulting cron command is validated and consists of five whitespace separated fields, which are either the letter '*' or a sorted, unique comma separated list of integers.
Parameters
- $cronCommand : string
Tags
Return values
stringconvertKeywordsToCronCommand()
Accept special cron command keywords and convert to standard cron syntax.
protected
static convertKeywordsToCronCommand(string $cronCommand) : string
Allowed keywords: @yearly, @annually, @monthly, @weekly, @daily, @midnight, @hourly
Parameters
- $cronCommand : string
Return values
stringconvertRangeToListOfValues()
Convert a range of integers to a list: 4-6 results in a string '4,5,6'
protected
static convertRangeToListOfValues(string $range) : string
Parameters
- $range : string
-
integer-integer
Tags
Return values
stringnormalizeFields()
Normalize cron command field to list of integers or *
protected
static normalizeFields(string $cronCommand) : string
Parameters
- $cronCommand : string
Return values
stringnormalizeIntegerField()
Normalize integer field.
protected
static normalizeIntegerField(string $expression[, int $lowerBound = 0 ][, int $upperBound = 59 ]) : string
Parameters
- $expression : string
- $lowerBound : int = 0
- $upperBound : int = 59
Tags
Return values
stringnormalizeMonth()
Accept a string representation or integer number of a month like 'jan', 'February', 01, ... and convert to normalized integer value between 1 and 12
protected
static normalizeMonth(string $month) : int
Parameters
- $month : string
Tags
Return values
intnormalizeMonthAndWeekday()
Dispatcher method for normalizeMonth and normalizeWeekday
protected
static normalizeMonthAndWeekday(string $expression[, bool $isMonth = true ]) : string
Parameters
- $expression : string
- $isMonth : bool = true
Return values
stringnormalizeMonthAndWeekdayField()
Normalize month field.
protected
static normalizeMonthAndWeekdayField(string $expression[, bool $isMonthField = true ]) : string
Parameters
- $expression : string
- $isMonthField : bool = true
Return values
stringnormalizeWeekday()
Accept a string representation or integer number of a weekday like 'mon', 'Friday', 3, ... and convert to normalized integer value between 1 and 7
protected
static normalizeWeekday(string $weekday) : int
Parameters
- $weekday : string
Tags
Return values
intreduceListOfValuesByStepValue()
Reduce a given list of values by step value.
protected
static reduceListOfValuesByStepValue(string $stepExpression) : string
Following a range with ``/
Parameters
- $stepExpression : string
Tags
Return values
string —comma-separated list of valid values
splitFields()
Split a given cron command like '23 * * * *' to an array with five fields.
protected
static splitFields(string $cronCommand) : array<string|int, mixed>
Parameters
- $cronCommand : string