class StringFormatter implements FormatterInterface, ValidationInterface, OverrideOptionsInterface (View source)

String formatter

This formatter is used as the default action when no particular formatter is requested. It will print the provided data only if it is a string; if any other type is given, then nothing is printed.

Methods

isValidDataType(ReflectionClass $dataType)

By default, we assume that we can convert any data type to string, unless it implements UnstructuredInterface, in which case we won't allow the string format unless the data type also implements StringTransformationInterface.

write(OutputInterface $output, mixed $data, FormatterOptions $options)

No description

overrideOptions(mixed $structuredOutput, FormatterOptions $options)

No description

reduceToSigleFieldAndWrite(OutputInterface $output, mixed $data, FormatterOptions $options)

If the data provided to a 'string' formatter is a table, then try to emit it in a simplified form (by default, TSV).

mixed
validate(mixed $structuredData)

Always validate any data, though. This format will never cause an error if it is selected for an incompatible data type; at worse, it simply does not print any data.

Details

isValidDataType(ReflectionClass $dataType)

By default, we assume that we can convert any data type to string, unless it implements UnstructuredInterface, in which case we won't allow the string format unless the data type also implements StringTransformationInterface.

Parameters

ReflectionClass $dataType

write(OutputInterface $output, mixed $data, FormatterOptions $options)

No description

Parameters

OutputInterface $output
mixed $data

Structured data to format

FormatterOptions $options

FormatterOptions overrideOptions(mixed $structuredOutput, FormatterOptions $options)

No description

Parameters

mixed $structuredOutput

Data to restructure

FormatterOptions $options

Formatting options

Return Value

FormatterOptions

protected reduceToSigleFieldAndWrite(OutputInterface $output, mixed $data, FormatterOptions $options)

If the data provided to a 'string' formatter is a table, then try to emit it in a simplified form (by default, TSV).

Parameters

OutputInterface $output
mixed $data
FormatterOptions $options

mixed validate(mixed $structuredData)

Always validate any data, though. This format will never cause an error if it is selected for an incompatible data type; at worse, it simply does not print any data.

Parameters

mixed $structuredData

Data to validate

Return Value

mixed