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])
Afficher le fichier Open project: webmozart/console Class Usage Examples

Méthodes publiques

Méthode 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

Méthode 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 méthode

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

addCells() public méthode

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

fit() public méthode

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 méthode

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

getColumnLengths() public méthode

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

getEstimatedNbColumns() public méthode

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.
Résultat integer The estimated number of columns.

getMaxTotalWidth() public méthode

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

getNbColumns() public méthode

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

getTotalWidth() public méthode

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

getWrappedRows() public méthode

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

hasWordCuts() public méthode

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

hasWordWraps() public méthode

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

setCells() public méthode

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