Table
class Table
Provides helpers to display a table.
Constants
SEPARATOR_TOP |
|
SEPARATOR_TOP_BOTTOM |
|
SEPARATOR_MID |
|
SEPARATOR_BOTTOM |
|
BORDER_OUTSIDE |
|
BORDER_INSIDE |
|
Methods
static
static TableStyle
getStyleDefinition(string $name)
Gets a style definition by name.
$this
getStyle()
Gets the current table style.
$this
getColumnStyle(int $columnIndex)
Gets the current style for a column.
$this
setColumnWidth(int $columnIndex, int $width)
Sets the minimum width of a column.
$this
setColumnWidths(array $widths)
Sets the minimum width of all columns.
setColumnMaxWidth(int $columnIndex, int $width)
Sets the maximum width of a column.
setHeaders(array $headers)
No description
setRows(array $rows)
No description
addRows(array $rows)
No description
addRow($row)
No description
setRow($column, array $row)
No description
setHeaderTitle(string|null $title)
No description
setFooterTitle(string|null $title)
No description
render()
Renders table to output.
Details
TableStyle
getColumnStyle(int $columnIndex)
Gets the current style for a column.
If style was not set, it returns the global table style.
Table
setColumnMaxWidth(int $columnIndex, int $width)
Sets the maximum width of a column.
Any cell within this column which contents exceeds the specified width will be wrapped into multiple lines, while formatted strings are preserved.
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 |
+---------------+-----------------------+------------------+