TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
NormalizeCommand Class Reference
Inheritance diagram for NormalizeCommand:
NormalizeCommandAccessibleProxy

Static Public Member Functions

static normalize ($cronCommand)
 

Static Protected Member Functions

static convertKeywordsToCronCommand ($cronCommand)
 
static normalizeFields ($cronCommand)
 
static splitFields ($cronCommand)
 
static normalizeMonthAndWeekdayField ($expression, $isMonthField=true)
 
static normalizeIntegerField ($expression, $lowerBound=0, $upperBound=59)
 
static convertRangeToListOfValues ($range)
 
static reduceListOfValuesByStepValue ($stepExpression)
 
static normalizeMonthAndWeekday ($expression, $isMonth=true)
 
static normalizeMonth ($month)
 
static normalizeWeekday ($weekday)
 

Detailed Description

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'

Definition at line 26 of file NormalizeCommand.php.

Member Function Documentation

static convertKeywordsToCronCommand (   $cronCommand)
staticprotected

Accept special cron command keywords and convert to standard cron syntax. Allowed keywords: , , , , , ,

Parameters
string$cronCommandCron command
Returns
string Normalized cron command if keyword was found, else unchanged cron command

Definition at line 55 of file NormalizeCommand.php.

static convertRangeToListOfValues (   $range)
staticprotected

Convert a range of integers to a list: 4-6 results in a string '4,5,6'

Exceptions
InvalidArgumentException If range can not be converted to list
Parameters
string$rangeInteger-integer
Returns
array

Definition at line 217 of file NormalizeCommand.php.

References MathUtility\canBeInterpretedAsInteger().

static normalize (   $cronCommand)
static

Main API method: Get the cron command and normalize it.

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.

Exceptions
InvalidArgumentException cron command is invalid or out of bounds
Parameters
string$cronCommandThe cron command to normalize
Returns
string Normalized cron command

Definition at line 40 of file NormalizeCommand.php.

Referenced by CronCommand\__construct(), and NormalizeCommandTest\normalizeConvertsCronCommand().

static normalizeFields (   $cronCommand)
staticprotected

Normalize cron command field to list of integers or *

Parameters
string$cronCommandcron command
Returns
string Normalized cron command

Definition at line 86 of file NormalizeCommand.php.

static normalizeIntegerField (   $expression,
  $lowerBound = 0,
  $upperBound = 59 
)
staticprotected

Normalize integer field.

Exceptions
InvalidArgumentException If field is invalid or out of bounds
Parameters
string$expressionExpression
int$lowerBoundLower limit of result list
int$upperBoundUpper limit of result list
Returns
string Normalized expression

Definition at line 166 of file NormalizeCommand.php.

References MathUtility\canBeInterpretedAsInteger().

static normalizeMonth (   $month)
staticprotected

Accept a string representation or integer number of a month like 'jan', 'February', 01, ... and convert to normalized integer value 1 .. 12

Exceptions
InvalidArgumentException If month string can not be converted to integer
Parameters
string$monthMonth representation
Returns
int month integer representation between 1 and 12

Definition at line 325 of file NormalizeCommand.php.

static normalizeMonthAndWeekday (   $expression,
  $isMonth = true 
)
staticprotected

Dispatcher method for normalizeMonth and normalizeWeekday

Parameters
string$expressionMonth or weekday to be normalized
bool$isMonthTRUE if a month is handled, FALSE for weekday
Returns
string normalized month or weekday

Definition at line 311 of file NormalizeCommand.php.

static normalizeMonthAndWeekdayField (   $expression,
  $isMonthField = true 
)
staticprotected

Normalize month field.

Parameters
string$expressionMonth field expression
bool$isMonthFieldTRUE if month field is handled, FALSE for weekday field
Returns
string Normalized expression

Definition at line 121 of file NormalizeCommand.php.

static normalizeWeekday (   $weekday)
staticprotected

Accept a string representation or integer number of a weekday like 'mon', 'Friday', 3, ... and convert to normalized integer value 1 .. 7

Exceptions
InvalidArgumentException If weekday string can not be converted
Parameters
string$weekdayWeekday representation
Returns
int weekday integer representation between 1 and 7

Definition at line 343 of file NormalizeCommand.php.

static reduceListOfValuesByStepValue (   $stepExpression)
staticprotected

Reduce a given list of values by step value. Following a range with ``/<number>'' specifies skips of the number's value through the range. 1-5/2 -> 1,3,5 2-10/3 -> 2,5,8

Exceptions
InvalidArgumentException if step value is invalid or if resulting list is empty
Parameters
string$stepExpressionStep value expression
Returns
string Comma separated list of valid values

Definition at line 261 of file NormalizeCommand.php.

References MathUtility\canBeInterpretedAsInteger().

static splitFields (   $cronCommand)
staticprotected

Split a given cron command like '23 * * * *' to an array with five fields.

Exceptions
InvalidArgumentException If splitted array does not contain five entries
Parameters
string$cronCommandcron command
Returns
array

Definition at line 105 of file NormalizeCommand.php.

References $fields.