[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/splitbrain/php-cli/src/ -> TableFormatter.php (summary)

(no description)

File Size: 325 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

TableFormatter:: (12 methods):
  __construct()
  getBorder()
  setBorder()
  getMaxWidth()
  setMaxWidth()
  getTerminalWidth()
  calculateColLengths()
  format()
  pad()
  strlen()
  substr()
  wordwrap()


Class: TableFormatter  - X-Ref

Class TableFormatter

Output text in multiple columns

__construct(Colors $colors = null)   X-Ref
TableFormatter constructor.

param: Colors|null $colors

getBorder()   X-Ref
The currently set border (defaults to ' ')

return: string

setBorder($border)   X-Ref
Set the border. The border is set between each column. Its width is
added to the column widths.

param: string $border

getMaxWidth()   X-Ref
Width of the terminal in characters

initially autodetected

return: int

setMaxWidth($max)   X-Ref
Set the width of the terminal to assume (in characters)

param: int $max

getTerminalWidth()   X-Ref
Tries to figure out the width of the terminal

return: int terminal width, 0 if unknown

calculateColLengths($columns)   X-Ref
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

param: array $columns
return: int[]

format($columns, $texts, $colors = array()   X-Ref
Displays text in multiple word wrapped columns

param: int[] $columns list of column widths (in characters, percent or '*')
param: string[] $texts list of texts for each column
param: array $colors A list of color names to use for each column. use empty string for default
return: string

pad($string, $len)   X-Ref
Pad the given string to the correct length

param: string $string
param: int $len
return: string

strlen($string)   X-Ref
Measures char length in UTF-8 when possible

param: $string
return: int

substr($string, $start = 0, $length = null)   X-Ref

param: string $string
param: int $start
param: int|null $length
return: string

wordwrap($str, $width = 75, $break = "\n", $cut = false)   X-Ref

link: http://stackoverflow.com/a/4988494
param: string $str
param: int $width
param: string $break
param: bool $cut
return: string