interface ValidDataTypesInterface implements ValidationInterface (View source)

Formatters may implement ValidDataTypesInterface in order to indicate exactly which formats they support. The validDataTypes method can be called to retrieve a list of data types useful in providing hints in exception messages about which data types can be used with the formatter.

Note that it is OPTIONAL for formatters to implement this interface. If a formatter implements only ValidationInterface, then clients that request the formatter via FormatterManager::write() will still get a list (via an InvalidFormatException) of all of the formats that are usable with the provided data type. Implementing ValidDataTypesInterface is benefitial to clients who instantiate a formatter directly (via new).

Formatters that implement ValidDataTypesInterface may wish to use ValidDataTypesTrait.

Methods

isValidDataType(ReflectionClass $dataType)

Return true if the specified format is valid for use with this formatter.

mixed
validate(mixed $structuredData)

Throw an IncompatibleDataException if the provided data cannot be processed by this formatter. Return the source data if it is valid. The data may be encapsulated or converted if necessary.

validDataTypes()

Return the list of data types acceptable to this formatter

Details

isValidDataType(ReflectionClass $dataType)

Return true if the specified format is valid for use with this formatter.

Parameters

ReflectionClass $dataType

mixed validate(mixed $structuredData)

Throw an IncompatibleDataException if the provided data cannot be processed by this formatter. Return the source data if it is valid. The data may be encapsulated or converted if necessary.

Parameters

mixed $structuredData

Data to validate

Return Value

mixed

ReflectionClass[] validDataTypes()

Return the list of data types acceptable to this formatter

Return Value

ReflectionClass[]