Valdi\Validator\AbstractDateTimeComparator

class AbstractDateTimeComparator

Abstract validator to compare date times. For the format, see: http://php.net/manual/en/datetime.createfromformat.php

property amountOfParameters

protected

Holds the amount of parameters.

property type

protected

Holds the type of the validator.

property dateTimeParameters

protected

Holds whether to parse the parameters as DateTimes so the child class can decide.

isValidComparison(DateTime $date, $datetimes, $parameters)

Compares date times.

Parameters:
  • $date (DateTime) – the first date to compare
  • $datetimes (DateTime[]) – the date times to compare to
  • $parameters (array) – the original validator parameters
Returns:

boolean true if the dates compare

getDateTimeFormat($parameters)

Gets a date time format from the parameters if given or a default one.

Parameters:
  • $parameters (string[]) – the parameters
Returns:

string the date time format

getDateTimes($parameters, $format)

Interprets the given parameters as date times and returns them.

Parameters:
  • $parameters (array) – the parameters
  • $format (string) – the date time format
Returns:

DateTime[] the date times

isValid($value, $parameters)

{@inheritdoc}

Parameters:
  • $value
  • $parameters
getInvalidDetails()

{@inheritdoc}

validateParameterCount($name, $parameterAmount, $parameters)

Throws an exception if the parameters don’t fulfill the expected parameter count.

Parameters:
  • $name (string) – the name of the validator
  • $parameterAmount (integer) – the amount of expected parameters
  • $parameters (string[]) – the parameters