class TsvFormatter extends CsvFormatter (View source)

Tab-separated value formatters

Display the provided structured data in a tab-separated list. Output escaping is much lighter, since there is no allowance for altering the delimiter.

Traits

Provides a default implementation of isValidDataType.

Methods

validDataTypes()

Return the list of data types acceptable to this formatter

isValidDataType(ReflectionClass $dataType)

Return the list of data types acceptable to this formatter

renderData($originalData, $restructuredData, FormatterOptions $options)

No description

renderEachCell($originalData, $restructuredData, FormatterOptions $options)

No description

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.

array
getDefaultFormatterOptions()

Return default values for formatter options

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

No description

writeOneLine(OutputInterface $output, array $data, FormatterOptions $options)

Writes a single a single line of formatted CSV data to the output stream.

string|bool
csvEscape(array $data, string $delimiter = ',', string $enclosure = '"', string $escapeChar = "\\")

Generates a CSV-escaped string from an array of field data.

tsvEscape($data)

No description

Details

abstract ReflectionClass[] validDataTypes()

Return the list of data types acceptable to this formatter

Return Value

ReflectionClass[]

isValidDataType(ReflectionClass $dataType)

Return the list of data types acceptable to this formatter

Parameters

ReflectionClass $dataType

renderData($originalData, $restructuredData, FormatterOptions $options)

No description

Parameters

$originalData
$restructuredData
FormatterOptions $options

protected renderEachCell($originalData, $restructuredData, FormatterOptions $options)

No description

Parameters

$originalData
$restructuredData
FormatterOptions $options

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

protected array getDefaultFormatterOptions()

Return default values for formatter options

Return Value

array

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

No description

Parameters

OutputInterface $output
mixed $data

Structured data to format

FormatterOptions $options

protected writeOneLine(OutputInterface $output, array $data, FormatterOptions $options)

Writes a single a single line of formatted CSV data to the output stream.

Parameters

OutputInterface $output

the output stream to write to.

array $data

an array of field data to convert to a CSV string.

FormatterOptions $options

the specified options for this formatter.

protected string|bool csvEscape(array $data, string $delimiter = ',', string $enclosure = '"', string $escapeChar = "\\")

Generates a CSV-escaped string from an array of field data.

Parameters

array $data

an array of field data to format as a CSV.

string $delimiter

the delimiter to use between fields.

string $enclosure

character to use when enclosing complex fields.

string $escapeChar

character to use when escaping special characters.

Return Value

string|bool

the formatted CSV string, or FALSE if the formatting failed.

protected tsvEscape($data)

No description

Parameters

$data