PHP Class Webmozart\Console\UI\Component\Table

You can add rows to the table with {@link addRow()}. You may optionally set a header row with {@link setHeaderRow()}. If you want to style the table, pass a {@link TableStyle} instance to the constructor.
Since: 1.0
Author: Bernhard Schussek ([email protected])
Inheritance: implements Webmozart\Console\UI\Component
显示文件 Open project: webmozart/console Class Usage Examples

Public Methods

Method Description
__construct ( TableStyle $style = null ) Creates a new table.
addRow ( array $row ) : static Adds a row to the table.
addRows ( array $rows ) : static Adds rows to the table.
render ( IO $io, integer $indentation ) Renders the table.
setHeaderRow ( array $row ) : static Sets the header cells of the table.
setRow ( integer $index, array $row ) : static Sets a specific row in the table.
setRows ( array $rows ) : static Sets the rows in the table.

Private Methods

Method Description
getCellWrapper ( Webmozart\Console\Api\Formatter\Formatter $formatter, $screenWidth, $excessColumnWidth, $indentation )
renderRows ( IO $io, array $rows, array $columnLengths, $excessColumnLength, $indentation )

Method Details

__construct() public method

Creates a new table.
public __construct ( TableStyle $style = null )
$style Webmozart\Console\UI\Style\TableStyle The rendering style. By default, the table is rendered with the style {@link TableStyle::asciiBorder()}.

addRow() public method

Adds a row to the table.
public addRow ( array $row ) : static
$row array An array of data cells.
return static The current instance.

addRows() public method

Adds rows to the table.
public addRows ( array $rows ) : static
$rows array The rows to add.
return static The current instance.

render() public method

Renders the table.
public render ( IO $io, integer $indentation )
$io Webmozart\Console\Api\IO\IO The I/O.
$indentation integer The number of spaces to indent.

setHeaderRow() public method

Sets the header cells of the table.
public setHeaderRow ( array $row ) : static
$row array The header cells.
return static The current instance.

setRow() public method

Sets a specific row in the table.
public setRow ( integer $index, array $row ) : static
$index integer The row index.
$row array An array of data cells.
return static The current instance.

setRows() public method

Sets the rows in the table.
public setRows ( array $rows ) : static
$rows array The rows to set.
return static The current instance.