Class TableFormatter
Class TableFormatter
Output text in multiple columns
Direct known subclasses
splitbrain\phpcli\tests\TableFormatterLicense: MIT
Author: Andreas Gohr andi@splitbrain.org
Located at src/TableFormatter.php
public
__construct( splitbrain\phpcli\Colors
$colors = null )
TableFormatter constructor.
TableFormatter constructor.
Parameters
- $colors
public
string
public
public
integer
getMaxWidth( )
Width of the terminal in characters
Width of the terminal in characters
initially autodetected
Returns
public
setMaxWidth( integer $max )
Set the width of the terminal to assume (in characters)
Set the width of the terminal to assume (in characters)
Parameters
- $max
protected
integer
getTerminalWidth( )
Tries to figure out the width of the terminal
Tries to figure out the width of the terminal
Returns
terminal width, 0 if unknown
protected
int[]
calculateColLengths( array $columns )
Takes an array with dynamic column width and calculates the correct width
Takes an array with dynamic column width and calculates the correct width
Column width can be given as fixed char widths, percentages and a single * width can be given for taking the remaining available space. When mixing percentages and fixed widths, percentages refer to the remaining space after allocating the fixed width
Parameters
- $columns
Returns
Throws
public
string
format( int[] $columns, string[] $texts, array $colors = array() )
Displays text in multiple word wrapped columns
Displays text in multiple word wrapped columns
Parameters
- $columns
- list of column widths (in characters, percent or '*')
- $texts
- list of texts for each column
- $colors
- A list of color names to use for each column. use empty string for default
Returns
Throws
protected
string
protected
integer
protected
string