Overview

Namespaces

  • Webmozart
    • Console
      • Adapter
      • Api
        • Application
        • Args
          • Format
        • Command
        • Config
        • Event
        • Formatter
        • IO
        • Resolver
      • Args
      • Config
      • Formatter
      • Handler
        • Help
      • IO
        • InputStream
        • OutputStream
      • Process
      • Resolver
      • UI
        • Alignment
        • Component
        • Help
        • Layout
        • Style
      • Util

Classes

  • BorderUtil
  • CellWrapper
  • EmptyLine
  • ExceptionTrace
  • Grid
  • LabeledParagraph
  • NameVersion
  • Paragraph
  • Table
  • Overview
  • Namespace
  • Class

Class CellWrapper

Wraps cells to fit a given screen width with a given number of columns.

You can add data cells with Webmozart\Console\UI\Component\CellWrapper::addCell(). Call Webmozart\Console\UI\Component\CellWrapper::fit() to fit the cells into a given maximum width and number of columns.

You can access the rows with the wrapped cells with Webmozart\Console\UI\Component\CellWrapper::getWrappedRows().

Namespace: Webmozart\Console\UI\Component
Author: Bernhard Schussek bschussek@gmail.com
Since: 1.0
Located at UI/Component/CellWrapper.php
Methods summary
public
# addCell( string $cell )

Adds a cell to the wrapper.

Adds a cell to the wrapper.

Parameters

$cell
The data cell.
public
# addCells( array $cells )

Adds cells to the wrapper.

Adds cells to the wrapper.

Parameters

$cells
The data cells.
public
# setCells( array $cells )

Sets the data cells in the wrapper.

Sets the data cells in the wrapper.

Parameters

$cells
The data cells.
public string[]
# getCells( )

Returns the data cells in the wrapper.

Returns the data cells in the wrapper.

Returns

string[]
The data cells.
public string[][]
# getWrappedRows( )

Returns the wrapped cells organized by rows and columns.

Returns the wrapped cells organized by rows and columns.

The method Webmozart\Console\UI\Component\CellWrapper::fit() should be called before accessing this method. Otherwise, an empty array is returned.

Returns

string[][]

An array of arrays. The first level represents rows, the second level the cells in each row.

public int[]
# getColumnLengths( )

Returns the lengths of the wrapped columns.

Returns the lengths of the wrapped columns.

The method Webmozart\Console\UI\Component\CellWrapper::fit() should be called before accessing this method. Otherwise, an empty array is returned.

Returns

int[]
The lengths of each column.
public integer
# getNbColumns( )

Returns the number of wrapped columns.

Returns the number of wrapped columns.

The method Webmozart\Console\UI\Component\CellWrapper::fit() should be called before accessing this method. Otherwise this method returns zero.

Returns

integer
The number of columns.
public integer
# getEstimatedNbColumns( integer $maxTotalWidth )

Returns an estimated number of columns for the given maximum width.

Returns an estimated number of columns for the given maximum width.

Parameters

$maxTotalWidth
The maximum total width of the columns.

Returns

integer
The estimated number of columns.
public integer
# getMaxTotalWidth( )

Returns the maximum allowed total width of the columns.

Returns the maximum allowed total width of the columns.

The method Webmozart\Console\UI\Component\CellWrapper::fit() should be called before accessing this method. Otherwise this method returns zero.

Returns

integer
The maximum allowed total width.
public integer
# getTotalWidth( )

Returns the actual total column width.

Returns the actual total column width.

The method Webmozart\Console\UI\Component\CellWrapper::fit() should be called before accessing this method. Otherwise this method returns zero.

Returns

integer
The actual total column width.
public boolean
# hasWordWraps( )

Returns whether any of the cells needed to be wrapped into multiple lines.

Returns whether any of the cells needed to be wrapped into multiple lines.

The method Webmozart\Console\UI\Component\CellWrapper::fit() should be called before accessing this method. Otherwise this method returns false.

Returns

boolean

Returns true if a cell was wrapped into multiple lines and false otherwise.

public boolean
# hasWordCuts( )

Returns whether any of the cells contains words cut in two.

Returns whether any of the cells contains words cut in two.

The method Webmozart\Console\UI\Component\CellWrapper::fit() should be called before accessing this method. Otherwise this method returns false.

Returns

boolean

Returns true if a cell contains words cut in two and false otherwise.

public
# 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.

Fits the added cells into the given maximum total width with the given number of columns.

Parameters

$maxTotalWidth
The maximum total width of the columns.
$nbColumns
The number of columns to use.
$formatter
The formatter used to remove style tags.
Webmozart Console API API documentation generated by ApiGen