The Clico Table class allows for formatting tabular data for the CLI stdOut.

It utilizes the Text class to allow for decorating text for the CLI stdOut.

package Default

 Methods

Call Text decorator methods

__call(string $method, Array $args) : \Webbtj\Clico\Table

A catch-all used to send Text decoration methods down to table column(s)

Parameters

$method

string

$args

Array

Returns

\Webbtj\Clico\Table

Constructor

__construct(Array $data = null, boolean $firstRowAsHeader = true

Can optionally populate the data. Can optionally set the first row of data as the header row.

Parameters

$data

Array

$firstRowAsHeader

boolean

Render the entire table using Text instances

__toString() : string

Returns

string

Add a header row

addHeader(Array $row) : \Webbtj\Clico\Table

Add a header row. Unsets the previous header row.

Parameters

$row

Array

Returns

\Webbtj\Clico\Table

Add a row

addRow(\Webbtj\Clico\Row $row) : \Webbtj\Clico\Table

Parameters

$row

\Webbtj\Clico\Row

Returns

\Webbtj\Clico\Table

Target a specific cell for text decoration

cell(integer $column, integer $row) : \Webbtj\Clico\Table

Parameters

$column

integer

$row

integer

Returns

\Webbtj\Clico\Table

Target an entire column for text decoration

column(integer $index = null) : \Webbtj\Clico\Table

Parameters

$index

integer

Returns

\Webbtj\Clico\Table

Fit all columns to the table (width and height)

distributeColumns(integer $maxWidth = 160) : \Webbtj\Clico\Table

Parameters

$maxWidth

integer

Returns

\Webbtj\Clico\Table

Get the header separator character

getHeaderLineCharacter() : \Webbtj\Clico\Text

Get the character (decorated) used to separate the header row from the body

Returns

\Webbtj\Clico\Text

Get the number of rows high

getHeight() : void

Get the column separator character

getPipeCharacter() : \Webbtj\Clico\Text

Get the character (decorated) used to separate columns

Returns

\Webbtj\Clico\Text

Get the row separator character

getRowLineCharacter() : \Webbtj\Clico\Text

Get the character (decorated) used to separate body rows

Returns

\Webbtj\Clico\Text

Get the number of columns wide

getWidth() : integer

Returns

integer

Format table, bulk add rows

populate(Array $data = null) : \Webbtj\Clico\Table

Reformat Rows' and Columns' widths, heights, and separation characters as necessary. Optionally add rows of data to the table

Parameters

$data

Array

Returns

\Webbtj\Clico\Table

Target an entire row for text decoration

row(integer $index = null) : \Webbtj\Clico\Table

Parameters

$index

integer

Returns

\Webbtj\Clico\Table

Make the first row the header row

setFirstRowAsHeader() : \Webbtj\Clico\Table

Returns

\Webbtj\Clico\Table

Set the header separator character

setHeaderLineCharacter(String $char, boolean $pushToRows = true) : \Webbtj\Clico\Table

Set the character used to separate the header row from the body

Parameters

$char

String

$pushToRows

boolean

Returns

\Webbtj\Clico\Table

Set the column separator character

setPipeCharacter(String $char, boolean $pushToRows = true) : \Webbtj\Clico\Table

Set the character used to separate columns

Parameters

$char

String

$pushToRows

boolean

Returns

\Webbtj\Clico\Table

Set the row separator character

setRowLineCharacter(String $char, boolean $pushToRows = true) : \Webbtj\Clico\Table

Set the charater used to separate body rows

Parameters

$char

String

$pushToRows

boolean

Returns

\Webbtj\Clico\Table

Push the separation characters down to the rows

pushCharactersToRows() : void

 Properties

 

$accessColumn

$accessColumn 

Default

 

$accessRow

$accessRow 

Default

 

$headerLineCharacter

$headerLineCharacter 

Default

'='
 

$pipeCharacter

$pipeCharacter 

Default

'|'
 

$rowLineCharacter

$rowLineCharacter 

Default

'-'
 

$rows

$rows 

Default

array()