Skip to content

Commit 3eb5890

Browse files
committed
wip
1 parent c9c438f commit 3eb5890

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/Entropy/ConsoleTable.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,19 @@ public function render(): string
6363
$columnWidths = array_fill(0, $cols, 0);
6464

6565
// headers
66-
foreach ($this->headers as $i => $header) {
67-
$columnWidths[$i] = max($columnWidths[$i], $this->strlenVisible($header));
66+
foreach ($this->headers as $columId => $header) {
67+
$columnWidths[$columId] = max($columnWidths[$columId], $this->strlenVisible($header));
6868
}
6969

7070
// rows
7171
foreach ($this->rows as $row) {
72-
foreach ($row as $cellId => $cell) {
73-
$columnWidths[$cellId] = max($columnWidths[$cellId], $this->strlenVisible($cell));
72+
foreach ($row as $columnId => $cell) {
73+
$columnWidths[$columnId] = max($columnWidths[$columnId], $this->strlenVisible($cell));
7474
}
7575
}
7676

77+
dump($columnWidths);
78+
7779
$output = [];
7880

7981
// header
@@ -143,7 +145,7 @@ private function rowLine(array $row, array $widths): string
143145

144146
private function strlenVisible(string|Stringable $contents): int
145147
{
146-
$string = (string) preg_replace('/\e\[[0-9;]*[A-Za-z]/', '', (string) $contents) ?? $contents;
148+
$string = (string) preg_replace('#\e\[[0-9;]*[A-Za-z]#', '', (string) $contents);
147149

148150
return strlen($string);
149151
}

0 commit comments

Comments
 (0)