function Table::calculateColumnsWidth
Calculates columns widths.
1 call to Table::calculateColumnsWidth()
- Table::render in vendor/
symfony/ console/ Helper/ Table.php - Renders table to output.
File
-
vendor/
symfony/ console/ Helper/ Table.php, line 806
Class
- Table
- Provides helpers to display a table.
Namespace
Symfony\Component\Console\HelperCode
private function calculateColumnsWidth(iterable $groups) : void {
for ($column = 0; $column < $this->numberOfColumns; ++$column) {
$lengths = [];
foreach ($groups as $group) {
foreach ($group as $row) {
if ($row instanceof TableSeparator) {
continue;
}
foreach ($row as $i => $cell) {
if ($cell instanceof TableCell) {
$textContent = Helper::removeDecoration($this->output
->getFormatter(), $cell);
$textLength = Helper::width($textContent);
if ($textLength > 0) {
$contentColumns = mb_str_split($textContent, ceil($textLength / $cell->getColspan()));
foreach ($contentColumns as $position => $content) {
$row[$i + $position] = $content;
}
}
}
}
$lengths[] = $this->getCellWidth($row, $column);
}
}
$this->effectiveColumnWidths[$column] = max($lengths) + Helper::width($this->style
->getCellRowContentFormat()) - 2;
}
}