Documentation

Table
in package

Provides helpers to display a table.

Tags
author

Fabien Potencier fabien@symfony.com

author

Саша Стаменковић umpirsky@gmail.com

author

Abdellatif Ait boudad a.aitboudad@gmail.com

author

Max Grigorian maxakawizard@gmail.com

Table of Contents

Properties

$columnStyles  : array<string|int, mixed>
$columnWidths  : array<string|int, mixed>
User set column widths.
$effectiveColumnWidths  : array<string|int, mixed>
Column widths cache.
$headers  : array<string|int, mixed>
Table headers.
$numberOfColumns  : array<string|int, mixed>
Number of columns cache.
$output  : OutputInterface
$rows  : array<string|int, mixed>
Table rows.
$style  : TableStyle
$styles  : mixed

Methods

__construct()  : mixed
addRow()  : mixed
addRows()  : mixed
getColumnStyle()  : TableStyle
Gets the current style for a column.
getStyle()  : TableStyle
Gets the current table style.
getStyleDefinition()  : TableStyle
Gets a style definition by name.
render()  : mixed
Renders table to output.
setColumnStyle()  : $this
Sets table column style.
setColumnWidth()  : $this
Sets the minimum width of a column.
setColumnWidths()  : $this
Sets the minimum width of all columns.
setHeaders()  : mixed
setRow()  : mixed
setRows()  : mixed
setStyle()  : $this
Sets table style.
setStyleDefinition()  : mixed
Sets a style definition.
buildTableRows()  : mixed
calculateColumnsWidth()  : mixed
Calculates columns widths.
calculateNumberOfColumns()  : mixed
Calculate number of columns for this table.
cleanup()  : mixed
Called after rendering to cleanup cache data.
copyRow()  : array<string|int, mixed>
fillCells()  : array<string|int, mixed>
fill cells for a row that contains colspan > 1.
fillNextRows()  : array<string|int, mixed>
fill rows that contains rowspan > 1.
getCellWidth()  : int
Gets cell width.
getColumnSeparatorWidth()  : int
Gets column width.
getNumberOfColumns()  : int
Gets number of columns by row.
getRowColumns()  : array<string|int, mixed>
Gets list of columns for the given row.
initStyles()  : mixed
renderCell()  : mixed
Renders table cell with padding.
renderColumnSeparator()  : mixed
Renders vertical column separator.
renderRow()  : mixed
Renders table row.
renderRowSeparator()  : mixed
Renders horizontal header separator.
resolveStyle()  : mixed

Properties

$columnStyles

private array<string|int, mixed> $columnStyles = array()

$columnWidths

User set column widths.

private array<string|int, mixed> $columnWidths = array()

$effectiveColumnWidths

Column widths cache.

private array<string|int, mixed> $effectiveColumnWidths = array()

$headers

Table headers.

private array<string|int, mixed> $headers = array()

$numberOfColumns

Number of columns cache.

private array<string|int, mixed> $numberOfColumns

$rows

Table rows.

private array<string|int, mixed> $rows = array()

$styles

private static mixed $styles

Methods

addRow()

public addRow(mixed $row) : mixed
Parameters
$row : mixed

addRows()

public addRows(array<string|int, mixed> $rows) : mixed
Parameters
$rows : array<string|int, mixed>

getColumnStyle()

Gets the current style for a column.

public getColumnStyle(int $columnIndex) : TableStyle

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

Parameters
$columnIndex : int

Column index

Return values
TableStyle

getStyleDefinition()

Gets a style definition by name.

public static getStyleDefinition(string $name) : TableStyle
Parameters
$name : string

The style name

Return values
TableStyle

render()

Renders table to output.

public render() : mixed

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 | +---------------+-----------------------+------------------+

setColumnStyle()

Sets table column style.

public setColumnStyle(int $columnIndex, TableStyle|string $name) : $this
Parameters
$columnIndex : int

Column index

$name : TableStyle|string

The style name or a TableStyle instance

Return values
$this

setColumnWidth()

Sets the minimum width of a column.

public setColumnWidth(int $columnIndex, int $width) : $this
Parameters
$columnIndex : int

Column index

$width : int

Minimum column width in characters

Return values
$this

setColumnWidths()

Sets the minimum width of all columns.

public setColumnWidths(array<string|int, mixed> $widths) : $this
Parameters
$widths : array<string|int, mixed>
Return values
$this

setHeaders()

public setHeaders(array<string|int, mixed> $headers) : mixed
Parameters
$headers : array<string|int, mixed>

setRow()

public setRow(mixed $column, array<string|int, mixed> $row) : mixed
Parameters
$column : mixed
$row : array<string|int, mixed>

setRows()

public setRows(array<string|int, mixed> $rows) : mixed
Parameters
$rows : array<string|int, mixed>

setStyle()

Sets table style.

public setStyle(TableStyle|string $name) : $this
Parameters
$name : TableStyle|string

The style name or a TableStyle instance

Return values
$this

setStyleDefinition()

Sets a style definition.

public static setStyleDefinition(string $name, TableStyle $style) : mixed
Parameters
$name : string

The style name

$style : TableStyle

A TableStyle instance

buildTableRows()

private buildTableRows(mixed $rows) : mixed
Parameters
$rows : mixed

calculateColumnsWidth()

Calculates columns widths.

private calculateColumnsWidth(array<string|int, mixed> $rows) : mixed
Parameters
$rows : array<string|int, mixed>

calculateNumberOfColumns()

Calculate number of columns for this table.

private calculateNumberOfColumns() : mixed

cleanup()

Called after rendering to cleanup cache data.

private cleanup() : mixed

copyRow()

private copyRow(array<string|int, mixed> $rows, int $line) : array<string|int, mixed>
Parameters
$rows : array<string|int, mixed>
$line : int
Return values
array<string|int, mixed>

fillCells()

fill cells for a row that contains colspan > 1.

private fillCells(array<string|int, mixed> $row) : array<string|int, mixed>
Parameters
$row : array<string|int, mixed>
Return values
array<string|int, mixed>

fillNextRows()

fill rows that contains rowspan > 1.

private fillNextRows(array<string|int, mixed> $rows, int $line) : array<string|int, mixed>
Parameters
$rows : array<string|int, mixed>
$line : int
Return values
array<string|int, mixed>

getCellWidth()

Gets cell width.

private getCellWidth(array<string|int, mixed> $row, int $column) : int
Parameters
$row : array<string|int, mixed>
$column : int
Return values
int

getColumnSeparatorWidth()

Gets column width.

private getColumnSeparatorWidth() : int
Return values
int

getNumberOfColumns()

Gets number of columns by row.

private getNumberOfColumns(array<string|int, mixed> $row) : int
Parameters
$row : array<string|int, mixed>
Return values
int

getRowColumns()

Gets list of columns for the given row.

private getRowColumns(array<string|int, mixed> $row) : array<string|int, mixed>
Parameters
$row : array<string|int, mixed>
Return values
array<string|int, mixed>

initStyles()

private static initStyles() : mixed

renderCell()

Renders table cell with padding.

private renderCell(array<string|int, mixed> $row, int $column, string $cellFormat) : mixed
Parameters
$row : array<string|int, mixed>
$column : int
$cellFormat : string

renderColumnSeparator()

Renders vertical column separator.

private renderColumnSeparator() : mixed

renderRow()

Renders table row.

private renderRow(array<string|int, mixed> $row, string $cellFormat) : mixed

Example: | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |

Parameters
$row : array<string|int, mixed>
$cellFormat : string

renderRowSeparator()

Renders horizontal header separator.

private renderRowSeparator() : mixed

Example: +-----+-----------+-------+

resolveStyle()

private resolveStyle(mixed $name) : mixed
Parameters
$name : mixed

        
On this page

Search results