Table

class Table

Provides helpers to display a table.

Methods

__construct(OutputInterface $output)
static setStyleDefinition(string $name, TableStyle $style)

Sets a style definition.

static TableStyle getStyleDefinition(string $name)

Gets a style definition by name.

Table setStyle(TableStyle|string $name)

Sets table style.

TableStyle getStyle()

Gets the current table style.

Table setColumnStyle(int $columnIndex, TableStyle|string $name)

Sets table column style.

TableStyle getColumnStyle(int $columnIndex)

Gets the current style for a column.

Table setColumnWidth(int $columnIndex, int $width)

Sets the minimum width of a column.

Table setColumnWidths(array $widths)

Sets the minimum width of all columns.

setHeaders(array $headers)
setRows(array $rows)
addRows(array $rows)
addRow($row)
setRow($column, array $row)
render()

Renders table to output.

Details

__construct(OutputInterface $output)

Parameters

OutputInterface $output

static setStyleDefinition(string $name, TableStyle $style)

Sets a style definition.

Parameters

string $name The style name
TableStyle $style A TableStyle instance

static TableStyle getStyleDefinition(string $name)

Gets a style definition by name.

Parameters

string $name The style name

Return Value

TableStyle A TableStyle instance

Table setStyle(TableStyle|string $name)

Sets table style.

Parameters

TableStyle|string $name The style name or a TableStyle instance

Return Value

Table

TableStyle getStyle()

Gets the current table style.

Return Value

TableStyle

Table setColumnStyle(int $columnIndex, TableStyle|string $name)

Sets table column style.

Parameters

int $columnIndex Column index
TableStyle|string $name The style name or a TableStyle instance

Return Value

Table

TableStyle getColumnStyle(int $columnIndex)

Gets the current style for a column.

If style was not set, it returns the global table style.

Parameters

int $columnIndex Column index

Return Value

TableStyle

Table setColumnWidth(int $columnIndex, int $width)

Sets the minimum width of a column.

Parameters

int $columnIndex Column index
int $width Minimum column width in characters

Return Value

Table

Table setColumnWidths(array $widths)

Sets the minimum width of all columns.

Parameters

array $widths

Return Value

Table

setHeaders(array $headers)

Parameters

array $headers

setRows(array $rows)

Parameters

array $rows

addRows(array $rows)

Parameters

array $rows

addRow($row)

Parameters

$row

setRow($column, array $row)

Parameters

$column
array $row

render()

Renders table to output.

Example: +---------------+-----------------------+------------------+ | ISBN | Title | Author | +---------------+-----------------------+------------------+ | 99921-58-10-7 | Divine Comedy | Dante Alighieri | | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | +---------------+-----------------------+------------------+

doc_Symfony
2016-10-28 06:33:59
Comments
Leave a Comment

Please login to continue.