Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
ConsoleTable Class Reference

Public Member Functions

 setDatas ($datas)
 
 factorize ()
 
 getTable ()
 
 removeVGrid ($start=2)
 
 removeHGrid ($start=2)
 
 removeGrid ($hStart=2, $vStart=2)
 
 setPadding ($padding)
 
 setIndent ($indent)
 
 setBorderColor ($borderColor)
 
 setPreserveSpaceBefore ($preserveSpaceBefore)
 
 __toString ()
 

Static Public Member Functions

static borderColor ($text, $color=ConsoleFormatter::LIGHT_GRAY)
 Surround the text with a border of the specified color.
 
static borderType ($text, $type)
 Surround the text with a border of the specified type.
 
static table (array $datas, $part=null)
 Return a formated table for displaying the datas.
 

Data Fields

const TOP_LEFT = '╭'
 
const TOP_RIGHT = '╮'
 
const H_LINE = '─'
 
const V_LINE = '│'
 
const M_COL_TOP = '┬'
 
const M_COL_ROW = '┼'
 
const M_COL_BOTTOM = '┴'
 
const M_ROW_LEFT = '├'
 
const M_ROW_RIGHT = '┤'
 
const BOTTOM_LEFT = '╰'
 
const BOTTOM_RIGHT = '╯'
 
const BINARY_VALUES
 

Private Member Functions

 getCellOutput ($index, $row=null)
 Get the printable cell content.
 
 getVLine ()
 
 initializeBorders ()
 
 mb_str_pad ($str, $pad_len, $pad_str=' ', $dir=STR_PAD_RIGHT, $encoding=NULL)
 mb_str_pad version for multibyte encoding.
 
 getLineRow ($row, $yl)
 
 border ($row)
 
 getBorderValue ($row, $col)
 
 calculateColWidths ()
 Calculate the maximum width of each column.
 

Private Attributes

 $h_lines = []
 
 $v_lines = []
 
 $datas
 
 $colWidths
 
 $rowHeight
 
 $colCount
 
 $rowCount
 
 $padding = 5
 
 $indent = 0
 
 $borderColor = ConsoleFormatter::LIGHT_GRAY
 
 $preserveSpaceBefore = false
 

Detailed Description

Definition at line 6 of file ConsoleTable.php.

Member Function Documentation

◆ __toString()

__toString ( )

Definition at line 411 of file ConsoleTable.php.

◆ border()

border (   $row)
private

Definition at line 232 of file ConsoleTable.php.

◆ borderColor()

static borderColor (   $text,
  $color = ConsoleFormatter::LIGHT_GRAY 
)
static

Surround the text with a border of the specified color.

Parameters
string$text
string$color
Returns
string

Definition at line 365 of file ConsoleTable.php.

◆ borderType()

static borderType (   $text,
  $type 
)
static

Surround the text with a border of the specified type.

Parameters
string$text
string$typeone of error, success, info, warning
Returns
string

Definition at line 382 of file ConsoleTable.php.

◆ calculateColWidths()

calculateColWidths ( )
private

Calculate the maximum width of each column.

Returns
array

Definition at line 292 of file ConsoleTable.php.

◆ factorize()

factorize ( )

Definition at line 160 of file ConsoleTable.php.

◆ getBorderValue()

getBorderValue (   $row,
  $col 
)
private

Definition at line 243 of file ConsoleTable.php.

◆ getCellOutput()

getCellOutput (   $index,
  $row = null 
)
private

Get the printable cell content.

Parameters
integer$indexThe column index
array$rowThe table row
Returns
string

Definition at line 75 of file ConsoleTable.php.

◆ getLineRow()

getLineRow (   $row,
  $yl 
)
private

Definition at line 178 of file ConsoleTable.php.

◆ getTable()

getTable ( )

Definition at line 193 of file ConsoleTable.php.

◆ getVLine()

getVLine ( )
private

Definition at line 105 of file ConsoleTable.php.

◆ initializeBorders()

initializeBorders ( )
private

Definition at line 109 of file ConsoleTable.php.

◆ mb_str_pad()

mb_str_pad (   $str,
  $pad_len,
  $pad_str = ' ',
  $dir = STR_PAD_RIGHT,
  $encoding = NULL 
)
private

mb_str_pad version for multibyte encoding.

See also
http://php.net/manual/fr/function.str-pad.php#116244
Parameters
string$str
int$pad_len
string$pad_str
string$dir
string$encoding
Returns
string

Definition at line 125 of file ConsoleTable.php.

◆ removeGrid()

removeGrid (   $hStart = 2,
  $vStart = 2 
)

Definition at line 227 of file ConsoleTable.php.

◆ removeHGrid()

removeHGrid (   $start = 2)

Definition at line 220 of file ConsoleTable.php.

◆ removeVGrid()

removeVGrid (   $start = 2)

Definition at line 214 of file ConsoleTable.php.

◆ setBorderColor()

setBorderColor (   $borderColor)
Parameters
string$borderColor

Definition at line 354 of file ConsoleTable.php.

◆ setDatas()

setDatas (   $datas)

Definition at line 153 of file ConsoleTable.php.

◆ setIndent()

setIndent (   $indent)
Parameters
number$indent

Definition at line 346 of file ConsoleTable.php.

◆ setPadding()

setPadding (   $padding)
Parameters
number$padding

Definition at line 338 of file ConsoleTable.php.

◆ setPreserveSpaceBefore()

setPreserveSpaceBefore (   $preserveSpaceBefore)
Parameters
boolean$preserveSpaceBefore

Definition at line 407 of file ConsoleTable.php.

◆ table()

static table ( array  $datas,
  $part = null 
)
static

Return a formated table for displaying the datas.

Parameters
array$datas
?string$part
Returns
\Ubiquity\devtools\cmd\ConsoleTable

Definition at line 422 of file ConsoleTable.php.

Field Documentation

◆ $borderColor

Definition at line 62 of file ConsoleTable.php.

◆ $colCount

$colCount
private

Definition at line 54 of file ConsoleTable.php.

◆ $colWidths

$colWidths
private

Definition at line 46 of file ConsoleTable.php.

◆ $datas

$datas
private

Definition at line 40 of file ConsoleTable.php.

◆ $h_lines

$h_lines = []
private

Definition at line 32 of file ConsoleTable.php.

◆ $indent

$indent = 0
private

Definition at line 60 of file ConsoleTable.php.

◆ $padding

$padding = 5
private

Definition at line 58 of file ConsoleTable.php.

◆ $preserveSpaceBefore

$preserveSpaceBefore = false
private

Definition at line 64 of file ConsoleTable.php.

◆ $rowCount

$rowCount
private

Definition at line 56 of file ConsoleTable.php.

◆ $rowHeight

$rowHeight
private

Definition at line 52 of file ConsoleTable.php.

◆ $v_lines

$v_lines = []
private

Definition at line 34 of file ConsoleTable.php.

◆ BINARY_VALUES

◆ BOTTOM_LEFT

const BOTTOM_LEFT = '╰'

Definition at line 16 of file ConsoleTable.php.

◆ BOTTOM_RIGHT

const BOTTOM_RIGHT = '╯'

Definition at line 16 of file ConsoleTable.php.

◆ H_LINE

const H_LINE = '─'

Definition at line 10 of file ConsoleTable.php.

◆ M_COL_BOTTOM

const M_COL_BOTTOM = '┴'

Definition at line 12 of file ConsoleTable.php.

◆ M_COL_ROW

const M_COL_ROW = '┼'

Definition at line 12 of file ConsoleTable.php.

◆ M_COL_TOP

const M_COL_TOP = '┬'

Definition at line 12 of file ConsoleTable.php.

◆ M_ROW_LEFT

const M_ROW_LEFT = '├'

Definition at line 14 of file ConsoleTable.php.

◆ M_ROW_RIGHT

const M_ROW_RIGHT = '┤'

Definition at line 14 of file ConsoleTable.php.

◆ TOP_LEFT

const TOP_LEFT = '╭'

Definition at line 8 of file ConsoleTable.php.

◆ TOP_RIGHT

const TOP_RIGHT = '╮'

Definition at line 8 of file ConsoleTable.php.

◆ V_LINE

const V_LINE = '│'

Definition at line 10 of file ConsoleTable.php.


The documentation for this class was generated from the following file: