class CalculateWidths (View source)

Calculate column widths for table cells.

Influenced by Drush and webmozart/console.

Methods

__construct()

No description

calculate($availableWidth, ColumnWidths $dataWidths, ColumnWidths $minimumWidths)

Given the total amount of available space, and the width of the columns to place, calculate the optimum column widths to use.

calculateLongestCell($rows)

Calculate the longest cell data from any row of each of the cells.

calculateLongestWord($rows)

Calculate the longest word and longest line in the provided data.

calculateColumnWidths($rows, callable $fn)

No description

getShortColumns($availableWidth, ColumnWidths $dataWidths, ColumnWidths $minimumWidths)

Return all of the columns whose longest line length is less than or equal to the average width.

distributeLongColumns($availableWidth, ColumnWidths $dataWidths, ColumnWidths $minimumWidths)

Distribute the remainig space among the columns that were not included in the list of "short" columns.

static int
longestWordLength(string $str)

Return the length of the longest word in the string.

Details

__construct()

No description

calculate($availableWidth, ColumnWidths $dataWidths, ColumnWidths $minimumWidths)

Given the total amount of available space, and the width of the columns to place, calculate the optimum column widths to use.

Parameters

$availableWidth
ColumnWidths $dataWidths
ColumnWidths $minimumWidths

calculateLongestCell($rows)

Calculate the longest cell data from any row of each of the cells.

Parameters

$rows

calculateLongestWord($rows)

Calculate the longest word and longest line in the provided data.

Parameters

$rows

protected calculateColumnWidths($rows, callable $fn)

No description

Parameters

$rows
callable $fn

getShortColumns($availableWidth, ColumnWidths $dataWidths, ColumnWidths $minimumWidths)

Return all of the columns whose longest line length is less than or equal to the average width.

Parameters

$availableWidth
ColumnWidths $dataWidths
ColumnWidths $minimumWidths

distributeLongColumns($availableWidth, ColumnWidths $dataWidths, ColumnWidths $minimumWidths)

Distribute the remainig space among the columns that were not included in the list of "short" columns.

Parameters

$availableWidth
ColumnWidths $dataWidths
ColumnWidths $minimumWidths

static protected int longestWordLength(string $str)

Return the length of the longest word in the string.

Parameters

string $str

Return Value

int