PHP Class Webmozart\Console\UI\Component\CellWrapper

You can add data cells with {@link addCell()}. Call {@link fit()} to fit the cells into a given maximum width and number of columns. You can access the rows with the wrapped cells with {@link getWrappedRows()}.
Since: 1.0
Author: Bernhard Schussek ([email protected])
Show file Open project: webmozart/console Class Usage Examples

Public Methods

Method Description
addCell ( string $cell ) Adds a cell to the wrapper.
addCells ( array $cells ) Adds cells to the wrapper.
fit ( integer $maxTotalWidth, integer $nbColumns, Webmozart\Console\Api\Formatter\Formatter $formatter ) Fits the added cells into the given maximum total width with the given number of columns.
getCells ( ) : string[] Returns the data cells in the wrapper.
getColumnLengths ( ) : int[] Returns the lengths of the wrapped columns.
getEstimatedNbColumns ( integer $maxTotalWidth ) : integer Returns an estimated number of columns for the given maximum width.
getMaxTotalWidth ( ) : integer Returns the maximum allowed total width of the columns.
getNbColumns ( ) : integer Returns the number of wrapped columns.
getTotalWidth ( ) : integer Returns the actual total column width.
getWrappedRows ( ) : string[][] Returns the wrapped cells organized by rows and columns.
hasWordCuts ( ) : boolean Returns whether any of the cells contains words cut in two.
hasWordWraps ( ) : boolean Returns whether any of the cells needed to be wrapped into multiple lines.
setCells ( array $cells ) Sets the data cells in the wrapper.

Private Methods

Method Description
initRows ( Webmozart\Console\Api\Formatter\Formatter $formatter )
refreshColumnLength ( $col )
resetState ( $maxTotalWidth, $nbColumns )
wrapColumn ( $col, $columnLength, Webmozart\Console\Api\Formatter\Formatter $formatter )
wrapColumns ( Webmozart\Console\Api\Formatter\Formatter $formatter )

Method Details

addCell() public method

Adds a cell to the wrapper.
public addCell ( string $cell )
$cell string The data cell.

addCells() public method

Adds cells to the wrapper.
public addCells ( array $cells )
$cells array The data cells.

fit() public method

Fits the added cells into the given maximum total width with the given number of columns.
public fit ( integer $maxTotalWidth, integer $nbColumns, Webmozart\Console\Api\Formatter\Formatter $formatter )
$maxTotalWidth integer The maximum total width of the columns.
$nbColumns integer The number of columns to use.
$formatter Webmozart\Console\Api\Formatter\Formatter The formatter used to remove style tags.

getCells() public method

Returns the data cells in the wrapper.
public getCells ( ) : string[]
return string[] The data cells.

getColumnLengths() public method

The method {@link fit()} should be called before accessing this method. Otherwise, an empty array is returned.
public getColumnLengths ( ) : int[]
return int[] The lengths of each column.

getEstimatedNbColumns() public method

Returns an estimated number of columns for the given maximum width.
public getEstimatedNbColumns ( integer $maxTotalWidth ) : integer
$maxTotalWidth integer The maximum total width of the columns.
return integer The estimated number of columns.

getMaxTotalWidth() public method

The method {@link fit()} should be called before accessing this method. Otherwise this method returns zero.
public getMaxTotalWidth ( ) : integer
return integer The maximum allowed total width.

getNbColumns() public method

The method {@link fit()} should be called before accessing this method. Otherwise this method returns zero.
public getNbColumns ( ) : integer
return integer The number of columns.

getTotalWidth() public method

The method {@link fit()} should be called before accessing this method. Otherwise this method returns zero.
public getTotalWidth ( ) : integer
return integer The actual total column width.

getWrappedRows() public method

The method {@link fit()} should be called before accessing this method. Otherwise, an empty array is returned.
public getWrappedRows ( ) : string[][]
return string[][] An array of arrays. The first level represents rows, the second level the cells in each row.

hasWordCuts() public method

The method {@link fit()} should be called before accessing this method. Otherwise this method returns false.
public hasWordCuts ( ) : boolean
return boolean Returns `true` if a cell contains words cut in two and `false` otherwise.

hasWordWraps() public method

The method {@link fit()} should be called before accessing this method. Otherwise this method returns false.
public hasWordWraps ( ) : boolean
return boolean Returns `true` if a cell was wrapped into multiple lines and `false` otherwise.

setCells() public method

Sets the data cells in the wrapper.
public setCells ( array $cells )
$cells array The data cells.