Table
in package
Provides helpers to display a table.
Tags
Table of Contents
Methods
- __construct() : mixed
- addRow() : $this
- addRows() : $this
- appendRow() : $this
- Adds a row to the table, and re-renders the table.
- 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() : void
- Renders table to output.
- setColumnMaxWidth() : $this
- Sets the maximum width of a column.
- setColumnStyle() : $this
- Sets table column style.
- setColumnWidth() : $this
- Sets the minimum width of a column.
- setColumnWidths() : $this
- Sets the minimum width of all columns.
- setFooterTitle() : $this
- setHeaders() : $this
- setHeaderTitle() : $this
- setHorizontal() : $this
- setRow() : $this
- setRows() : $this
- setStyle() : $this
- Sets table style.
- setStyleDefinition() : void
- Sets a style definition.
- setVertical() : $this
Methods
__construct()
public
__construct(OutputInterface $output) : mixed
Parameters
- $output : OutputInterface
addRow()
public
addRow(TableSeparator|array<string|int, mixed> $row) : $this
Parameters
- $row : TableSeparator|array<string|int, mixed>
Return values
$thisaddRows()
public
addRows(array<string|int, mixed> $rows) : $this
Parameters
- $rows : array<string|int, mixed>
Return values
$thisappendRow()
Adds a row to the table, and re-renders the table.
public
appendRow(TableSeparator|array<string|int, mixed> $row) : $this
Parameters
- $row : TableSeparator|array<string|int, mixed>
Return values
$thisgetColumnStyle()
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
Return values
TableStylegetStyle()
Gets the current table style.
public
getStyle() : TableStyle
Return values
TableStylegetStyleDefinition()
Gets a style definition by name.
public
static getStyleDefinition(string $name) : TableStyle
Parameters
- $name : string
Return values
TableStylerender()
Renders table to output.
public
render() : void
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 | +---------------+-----------------------+------------------+
setColumnMaxWidth()
Sets the maximum width of a column.
public
setColumnMaxWidth(int $columnIndex, int $width) : $this
Any cell within this column which contents exceeds the specified width will be wrapped into multiple lines, while formatted strings are preserved.
Parameters
- $columnIndex : int
- $width : int
Return values
$thissetColumnStyle()
Sets table column style.
public
setColumnStyle(int $columnIndex, TableStyle|string $name) : $this
Parameters
- $columnIndex : int
- $name : TableStyle|string
-
The style name or a TableStyle instance
Return values
$thissetColumnWidth()
Sets the minimum width of a column.
public
setColumnWidth(int $columnIndex, int $width) : $this
Parameters
- $columnIndex : int
- $width : int
Return values
$thissetColumnWidths()
Sets the minimum width of all columns.
public
setColumnWidths(array<string|int, mixed> $widths) : $this
Parameters
- $widths : array<string|int, mixed>
Return values
$thissetFooterTitle()
public
setFooterTitle(string|null $title) : $this
Parameters
- $title : string|null
Return values
$thissetHeaders()
public
setHeaders(array<string|int, mixed> $headers) : $this
Parameters
- $headers : array<string|int, mixed>
Return values
$thissetHeaderTitle()
public
setHeaderTitle(string|null $title) : $this
Parameters
- $title : string|null
Return values
$thissetHorizontal()
public
setHorizontal([bool $horizontal = true ]) : $this
Parameters
- $horizontal : bool = true
Return values
$thissetRow()
public
setRow(int|string $column, array<string|int, mixed> $row) : $this
Parameters
- $column : int|string
- $row : array<string|int, mixed>
Return values
$thissetRows()
public
setRows(array<string|int, mixed> $rows) : $this
Parameters
- $rows : array<string|int, mixed>
Return values
$thissetStyle()
Sets table style.
public
setStyle(TableStyle|string $name) : $this
Parameters
- $name : TableStyle|string
Return values
$thissetStyleDefinition()
Sets a style definition.
public
static setStyleDefinition(string $name, TableStyle $style) : void
Parameters
- $name : string
- $style : TableStyle
setVertical()
public
setVertical([bool $vertical = true ]) : $this
Parameters
- $vertical : bool = true