StringFormatter
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
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.
If the data provided to a 'string' formatter is a table, then try to emit it in a simplified form (by default, TSV).
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.
write(OutputInterface $output, mixed $data, FormatterOptions $options)
No description
FormatterOptions
overrideOptions(mixed $structuredOutput, FormatterOptions $options)
No description
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).
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.