Skip to content

Commit 40c47da

Browse files
Revert "Refactor TableView to improve separator handling with distinct header and footer methods."
This reverts commit 998dab3.
1 parent 13c9ee7 commit 40c47da

1 file changed

Lines changed: 6 additions & 20 deletions

File tree

src/View/TableView.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function show(array $data): void
1919
$headers = $this->headers($data);
2020
$widths = $this->columnWidths($headers, $data);
2121

22-
$this->writeHeaderLine($widths);
22+
$this->writeLine($this->separator($widths));
2323
$this->writeLine($this->formatRow($headers, $widths));
2424
$this->writeLine($this->separator($widths));
2525

@@ -33,7 +33,7 @@ public function show(array $data): void
3333
$this->writeLine($this->formatRow(array_values($row), $widths));
3434
}
3535

36-
$this->writeFooterLine($widths);
36+
$this->writeLine($this->separator($widths));
3737
}
3838

3939
protected function headers(array $data): array
@@ -54,25 +54,11 @@ protected function columnWidths(array $headers, array $data): array
5454
return $widths;
5555
}
5656

57-
protected function writeHeaderLine(array $widths): void
58-
{
59-
$this->writeLine(
60-
$this->separator($widths, '', '', '')
61-
);
62-
}
63-
64-
protected function writeFooterLine(array $widths): void
65-
{
66-
$this->writeLine(
67-
$this->separator($widths, '', '', '')
68-
);
69-
}
70-
71-
protected function separator(array $widths, string $start = '', string $divider = '', string $end = ''): string
57+
protected function separator(array $widths): string
7258
{
73-
$parts = array_map(static fn (int $w) => str_repeat('', $w + 2), $widths);
59+
$parts = array_map(fn (int $w) => str_repeat('-', $w + 2), $widths);
7460

75-
return $start . implode($divider, $parts) . $end;
61+
return '+' . implode('+', $parts) . '+';
7662
}
7763

7864
protected function formatRow(array $values, array $widths): string
@@ -83,6 +69,6 @@ protected function formatRow(array $values, array $widths): string
8369
$cells[] = ' ' . mb_str_pad((string) $value, $widths[$i]) . ' ';
8470
}
8571

86-
return '' . implode('', $cells) . '';
72+
return '|' . implode('|', $cells) . '|';
8773
}
8874
}

0 commit comments

Comments
 (0)