Tables

Tables are first defined by the Column class. An array of columns is sent into the table constructor to define the structure of the columns.

There are currently three types of table classes:

The following is a BarTable:

The following is a Table with Markup:

Column

A column defines:

The default column is a calculated width, with three spaces along the right side, left justified with no colors. If the data sent into the table has rows with more columns than Columns specified in the constructor, the default Column will be used.

Software Documentation

The following sections lists the software documentation for:

Column Class

Constructor


The column constructor defining two key elements of a column, the header text and whether to calculate the width based on the data, or set a static width.

__construct($headerText = null, $width = null)

Parameters
NameTypeDescription
$headerText string | null The text of the header for this column or null if none is desired
$width int | null If left null, then it will be calculated based on the widest text, plus any padding, if an integer is sent in, then it will be the overall width (including the padding)

setHeaderText, getHeaderText, hasHeaderText


Setter and getter for the header text.

setHeaderText($headerText)
getHeaderText()
hasHeaderText()

Parameters
NameTypeDescription
$headerText string | null The text of the header for this column or null if none is desired

setWidth, getWidth


Setter and getter for the width. If the width is null, then it will be automatically calculated based on the widest data plus the padding. If it is set as a static number, then it will be overall width (including the headers)

setWidth($width)
getWidth()

Parameters
NameTypeDescription
$width int | null The width or null if calculated

setMaximumWidth, getMaximumWidth


Setter and getter for the maximum width. This value is only important when the width is set to be calculated. This number can then be used to create a stop gap width if some data is just too wide.

setMaximumWidth($maximumWidth)
getMaximumWidth()

Parameters
NameTypeDescription
$maximumWidth int | null The maximum width or null to allow even the widest data to dictate width

setRightPadding, setLeftPadding, setLeftPadding, getLeftPadding


Setter and getters for the left and right padding. Right padding should be used on every column to breathe space into the table. The left padding is mainly for the first column if there is fill, it helps to put in a one or two blank spaces to breathe.

setRightPadding($rightPadding)
getRightPadding()
setLeftPadding($leftPadding)
getLeftPadding()

Parameters
NameTypeDescription
$right(left)Padding int The number of blank characters

setJustification, getJustification


Setter and getter for the justification. You can send in the strings, such as "left", "Right", or the Justification constants such as Justification::LEFT.

setJustification($justification)
getJustification()

Parameters
NameTypeDescription
$justification string | int - either a justification constant from HTML or "left", "Center"...etc the justification

setColors, getTextColor, getFillColor


Setter and getters for the column text and fill color.

setColors($textColor = null, $fillColor = null)
getTextColor()
getFillColor()

Parameters
NameTypeDescription
$textColor Any valid Color constructor initial value The text color
$fillColor Any valid Color constructor initial value The text color

Table Class

The Table class creates a simple table, which bolds the header, if specified.

Constructor


The Table constructor requires two parameter, the HTML object (which should be only one instance that represents the terminal) and an array of Column object to define the column structure.

__construct($html,$columnDefinitions)

Parameters
NameTypeDescription
$clio Clio Clio object
$columnDefinitions Column[] An array of Column objects defining column properties, if there are less Column definitions than column data, default Column objedts will be automatically created.

setColumnDefinition


Set the Column definition for one column.

setColumnDefinition($columnIndex, Column $column)

Parameters
NameTypeDescription
$columnIndex integer The column index for the defined definition
$columnDefinitions Column A Column object defining column properties

draw


Draw the data, which is a multidimensional array of rows, which are array of cells for each row.

draw($data)

Parameters
NameTypeDescription
$data string[][] Array of row data

BarTable Class

The Bar Title has an (optional) overarching title along the top with no columns and a single title. Below that will be the column headers. Both of these lines are filled with specified text and fill color, with an optional line at the bottom to round it out.

Constructor


The BarTable constructor requires one parameter, the Clio object (which should be only one instance that represents the terminal). A title can also be specified which will span the whole table, as well as whether to have a small stylistic line at the bottom of the table (which works well if there are fill colors).

__construct($clio, $columns, $title = null, $showBottomLine = true)

Parameters
NameTypeDescription
$clio Clio Clio object
$columnDefinitions Column[] An array of Column objects defining column properties, if there are less Column definitions than column data, default Column objedts will be automatically created.
$title string A title that runs across the entire table
$showBottomLine boolean Whether to show a stylistic line at the bottom of the table.

setTitle


Set the title for the entire table.

setTitle($text)

Parameters
NameTypeDescription
$text string The title (which will be truncated if wider than the table)

setColors


Set the color scheme for the table. The bar text and fill will color the title and the headers, the body text and fill will color the data.

setColors($barText, $barFill, $bodyText, $bodyFill)

Parameters
NameTypeDescription
$barText Any valid Color constructor initial value The title and header text color
$barFill Any valid Color constructor initial value The title and header fill color
$bodyText Any valid Color constructor initial value The text color of the table data
$bodyFill Any valid Color constructor initial value The fill color of the table data

setShowBottomLine


Whether to add a closing line at the bottom of the table, which can look nice when the $bodyFill color is set.

setShowBottomLine($showBottomLine)

Parameters
NameTypeDescription
$showBottomLine booolean Whether to show the bottom line

draw


Draw the data, which is a multidimensional array of rows, which are array of cells for each row.

draw($data)

Parameters
NameTypeDescription
$data string[][] Array of row data

AlternatingTable Class

The AlternatingTable class draws a table similar to the Table class, except there is an alternating color for the rows of data.

Constructor


The AlternatingTable constructor requires one parameter, the HTML object (which should be only one instance that represents the terminal). The alternating background can also be set. It is defaulted to Old Lace, which is a light yellow.

__construct($html, $columns, $alternatingBackground = "oldlace")

Parameters
NameTypeDescription
$html Clio Clio HTML object
$columnDefinitions Column[] An array of Column objects defining column properties, if there are less Column definitions than column data, default Column objedts will be automatically created.
$alternatingBackground Any valid Color constructor initial value The fill color of every other line

setAlternatingFill


Set the fill color for everything row.

setAlternatingFill($alternatingBackground)

Parameters
NameTypeDescription
$alternatingBackground Any valid Color constructor initial value The fill color of every other line

draw


Draw the data, which is a multidimensional array of rows, which are array of cells for each row.

draw($data)

Parameters
NameTypeDescription
$data string[][] Array of row data