Page MenuHomePhorge

final class PhutilConsoleTable
Arcanist Technical Documentation ()

Show a table in the console. Usage:

$table = id(new PhutilConsoleTable())
  ->addColumn('id', array('title' => 'ID', 'align' => 'right'))
  ->addColumn('name', array('title' => 'Username', 'align' => 'center'))
  ->addColumn('email', array('title' => 'Email Address'))

  ->addRow(array(
    'id'    => 12345,
    'name'  => 'alicoln',
    'email' => 'abraham@lincoln.com',
  ))
  ->addRow(array(
    'id'    => 99999999,
    'name'  => 'jbloggs',
    'email' => 'joe@bloggs.com',
  ))

  ->setBorders(true)
  ->draw();

Methods

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

This method is not documented.
Parameters
$name
$value
Return
wild

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

Read the value of a class constant.

This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

protected function drawView()

This method is not documented.
Return
wild

final public function setConsole($console)
Inherited

This method is not documented.
Parameters
PhutilConsole$console
Return
wild

final public function getConsole()
Inherited

This method is not documented.
Return
wild

final public function draw()
Inherited

PhutilConsoleView

Draw a view to the console.

Return
this

final public function drawConsoleString()
Inherited

PhutilConsoleView

Draw a view to a string and return it.

Return
stringConsole-printable string.

private function reduceView($view)
Inherited

PhutilConsoleView

Reduce a view to a list of simple, unnested parts.

Parameters
wild$viewAny drawable view.
Return
list<wild>List of unnested drawables.

final protected function drawLines($parts)
Inherited

This method is not documented.
Parameters
list<wild>$partsList of views, one per line.
Return
wildEach view rendered on a separate line.

final protected function implode($separator, $items)
Inherited

This method is not documented.
Parameters
$separator
array$items
Return
wild

public function setBorders($borders)

This method is not documented.
Parameters
$borders
Return
wild

public function setPadding($padding)

This method is not documented.
Parameters
$padding
Return
wild

public function setShowHeader($show_header)

This method is not documented.
Parameters
$show_header
Return
wild

public function addColumn($key, $column)

This method is not documented.
Parameters
$key
array$column
Return
wild

public function addColumns($columns)

This method is not documented.
Parameters
array$columns
Return
wild

public function addRow($data)

This method is not documented.
Parameters
array$data
Return
wild

public function drawRows($rows)

This method is not documented.
Parameters
array$rows
Return
wild

private function getHeader()

This method is not documented.
Return
wild

private function getBody()

This method is not documented.
Return
wild

private function getFooter()

This method is not documented.
Return
wild

private function shouldAddSpacing($key, $column)

Returns if the specified column should have spacing added.

Parameters
$key
$column
Return
bool

protected function getColumns()

Returns the column IDs.

Return
list<string>

protected function getWidth($key)

Get the width of a specific column, including padding.

Parameters
string$key
Return
int

protected function alignString($string, $width, $align)

This method is not documented.
Parameters
$string
$width
$align
Return
wild

protected function formatRow($columns)

Format cells into an entire row.

Parameters
list<string>$columns
Return
string

protected function formatSeparator($string)

This method is not documented.
Parameters
$string
Return
wild