Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions src/View/TableView.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function show(array $data): void
$headers = $this->headers($data);
$widths = $this->columnWidths($headers, $data);

$this->writeHeaderLine($widths);
$this->writeLine($this->separator($widths));
$this->writeLine($this->formatRow($headers, $widths));
$this->writeLine($this->separator($widths));

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

$this->writeFooterLine($widths);
$this->writeLine($this->separator($widths));
}

protected function headers(array $data): array
Expand All @@ -54,25 +54,11 @@ protected function columnWidths(array $headers, array $data): array
return $widths;
}

protected function writeHeaderLine(array $widths): void
{
$this->writeLine(
$this->separator($widths, '┌', '┬', '┐')
);
}

protected function writeFooterLine(array $widths): void
{
$this->writeLine(
$this->separator($widths, '└', '┴', '┘')
);
}

protected function separator(array $widths, string $start = '├', string $divider = '┼', string $end = '┤'): string
protected function separator(array $widths): string
{
$parts = array_map(static fn (int $w) => str_repeat('', $w + 2), $widths);
$parts = array_map(fn (int $w) => str_repeat('-', $w + 2), $widths);

return $start . implode($divider, $parts) . $end;
return '+' . implode('+', $parts) . '+';
}

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

return '' . implode('', $cells) . '';
return '|' . implode('|', $cells) . '|';
}
}
20 changes: 10 additions & 10 deletions tests/.pest/snapshots/Unit/Result/ToConsoleTest/compare.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


┌───────┬───────────────────────────────┬──────────────────────────────┐
# 0 1
├───────┼───────────────────────────────┼──────────────────────────────┤
min 15.67890123 ms - 202 bytes 2.3456789 ms - 102 bytes
max 112.78901234 ms - 209 bytes 9.75678901 ms - 109 bytes
avg 53.02524845125 ms - 205 bytes 5.94290024625 ms - 105 bytes
total 424.20198761 ms - 1.61 KB 47.54320197 ms - 844 bytes
├───────┼───────────────────────────────┼──────────────────────────────┤
order 2 1
└───────┴───────────────────────────────┴──────────────────────────────┘
+-------+-------------------------------+------------------------------+
| # | 0 | 1 |
+-------+-------------------------------+------------------------------+
| min | 15.67890123 ms - 202 bytes | 2.3456789 ms - 102 bytes |
| max | 112.78901234 ms - 209 bytes | 9.75678901 ms - 109 bytes |
| avg | 53.02524845125 ms - 205 bytes | 5.94290024625 ms - 105 bytes |
| total | 424.20198761 ms - 1.61 KB | 47.54320197 ms - 844 bytes |
+-------+-------------------------------+------------------------------+
| order | 2 | 1 |
+-------+-------------------------------+------------------------------+
Expand Down
26 changes: 13 additions & 13 deletions tests/.pest/snapshots/Unit/Result/ToConsoleTest/deviations.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


┌──────────────────┬───────────────────────────────┬──────────────────────────────┐
# 0 1
├──────────────────┼───────────────────────────────┼──────────────────────────────┤
min 15.67890123 ms - 202 bytes 2.3456789 ms - 102 bytes
max 112.78901234 ms - 209 bytes 9.75678901 ms - 109 bytes
avg 53.02524845125 ms - 205 bytes 5.94290024625 ms - 105 bytes
total 848.40397522 ms - 3.21 KB 95.08640394 ms - 1.65 KB
├──────────────────┼───────────────────────────────┼──────────────────────────────┤
order 2 1
├──────────────────┼───────────────────────────────┼──────────────────────────────┤
deviation time 0% 0%
deviation memory 0% 0%
└──────────────────┴───────────────────────────────┴──────────────────────────────┘
+------------------+-------------------------------+------------------------------+
| # | 0 | 1 |
+------------------+-------------------------------+------------------------------+
| min | 15.67890123 ms - 202 bytes | 2.3456789 ms - 102 bytes |
| max | 112.78901234 ms - 209 bytes | 9.75678901 ms - 109 bytes |
| avg | 53.02524845125 ms - 205 bytes | 5.94290024625 ms - 105 bytes |
| total | 848.40397522 ms - 3.21 KB | 95.08640394 ms - 1.65 KB |
+------------------+-------------------------------+------------------------------+
| order | 2 | 1 |
+------------------+-------------------------------+------------------------------+
| deviation time | 0% | 0% |
| deviation memory | 0% | 0% |
+------------------+-------------------------------+------------------------------+
Expand Down
20 changes: 10 additions & 10 deletions tests/.pest/snapshots/Unit/Round/RoundTest/default.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


┌───────┬───────────────────────────────┬──────────────────────────────┐
# 0 1
├───────┼───────────────────────────────┼──────────────────────────────┤
min 15.67890123 ms - 202 bytes 2.3456789 ms - 102 bytes
max 112.78901234 ms - 209 bytes 9.75678901 ms - 109 bytes
avg 53.02524845125 ms - 205 bytes 5.94290024625 ms - 105 bytes
total 424.20198761 ms - 1.61 KB 47.54320197 ms - 844 bytes
├───────┼───────────────────────────────┼──────────────────────────────┤
order 2 1
└───────┴───────────────────────────────┴──────────────────────────────┘
+-------+-------------------------------+------------------------------+
| # | 0 | 1 |
+-------+-------------------------------+------------------------------+
| min | 15.67890123 ms - 202 bytes | 2.3456789 ms - 102 bytes |
| max | 112.78901234 ms - 209 bytes | 9.75678901 ms - 109 bytes |
| avg | 53.02524845125 ms - 205 bytes | 5.94290024625 ms - 105 bytes |
| total | 424.20198761 ms - 1.61 KB | 47.54320197 ms - 844 bytes |
+-------+-------------------------------+------------------------------+
| order | 2 | 1 |
+-------+-------------------------------+------------------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


┌───────┬────────────────────┬───────────────────┐
# 0 1
├───────┼────────────────────┼───────────────────┤
min 16 ms - 202 bytes 2 ms - 102 bytes
max 113 ms - 209 bytes 10 ms - 109 bytes
avg 53 ms - 205 bytes 6 ms - 105 bytes
total 424 ms - 1.61 KB 48 ms - 844 bytes
├───────┼────────────────────┼───────────────────┤
order 2 1
└───────┴────────────────────┴───────────────────┘
+-------+--------------------+-------------------+
| # | 0 | 1 |
+-------+--------------------+-------------------+
| min | 16 ms - 202 bytes | 2 ms - 102 bytes |
| max | 113 ms - 209 bytes | 10 ms - 109 bytes |
| avg | 53 ms - 205 bytes | 6 ms - 105 bytes |
| total | 424 ms - 1.61 KB | 48 ms - 844 bytes |
+-------+--------------------+-------------------+
| order | 2 | 1 |
+-------+--------------------+-------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


┌───────┬────────────────────┬───────────────────┐
# 0 1
├───────┼────────────────────┼───────────────────┤
min 16 ms - 202 bytes 2 ms - 102 bytes
max 113 ms - 209 bytes 10 ms - 109 bytes
avg 53 ms - 205 bytes 6 ms - 105 bytes
total 424 ms - 1.61 KB 48 ms - 844 bytes
├───────┼────────────────────┼───────────────────┤
order 2 1
└───────┴────────────────────┴───────────────────┘
+-------+--------------------+-------------------+
| # | 0 | 1 |
+-------+--------------------+-------------------+
| min | 16 ms - 202 bytes | 2 ms - 102 bytes |
| max | 113 ms - 209 bytes | 10 ms - 109 bytes |
| avg | 53 ms - 205 bytes | 6 ms - 105 bytes |
| total | 424 ms - 1.61 KB | 48 ms - 844 bytes |
+-------+--------------------+-------------------+
| order | 2 | 1 |
+-------+--------------------+-------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


┌───────┬───────────────────────┬──────────────────────┐
# 0 1
├───────┼───────────────────────┼──────────────────────┤
min 15.68 ms - 202 bytes 2.35 ms - 102 bytes
max 112.79 ms - 209 bytes 9.76 ms - 109 bytes
avg 53.03 ms - 205 bytes 5.94 ms - 105 bytes
total 424.2 ms - 1.61 KB 47.54 ms - 844 bytes
├───────┼───────────────────────┼──────────────────────┤
order 2 1
└───────┴───────────────────────┴──────────────────────┘
+-------+-----------------------+----------------------+
| # | 0 | 1 |
+-------+-----------------------+----------------------+
| min | 15.68 ms - 202 bytes | 2.35 ms - 102 bytes |
| max | 112.79 ms - 209 bytes | 9.76 ms - 109 bytes |
| avg | 53.03 ms - 205 bytes | 5.94 ms - 105 bytes |
| total | 424.2 ms - 1.61 KB | 47.54 ms - 844 bytes |
+-------+-----------------------+----------------------+
| order | 2 | 1 |
+-------+-----------------------+----------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


┌───────┬───────────────────────┬──────────────────────┐
# 0 1
├───────┼───────────────────────┼──────────────────────┤
min 15.68 ms - 202 bytes 2.35 ms - 102 bytes
max 112.79 ms - 209 bytes 9.76 ms - 109 bytes
avg 53.03 ms - 205 bytes 5.94 ms - 105 bytes
total 424.2 ms - 1.61 KB 47.54 ms - 844 bytes
├───────┼───────────────────────┼──────────────────────┤
order 2 1
└───────┴───────────────────────┴──────────────────────┘
+-------+-----------------------+----------------------+
| # | 0 | 1 |
+-------+-----------------------+----------------------+
| min | 15.68 ms - 202 bytes | 2.35 ms - 102 bytes |
| max | 112.79 ms - 209 bytes | 9.76 ms - 109 bytes |
| avg | 53.03 ms - 205 bytes | 5.94 ms - 105 bytes |
| total | 424.2 ms - 1.61 KB | 47.54 ms - 844 bytes |
+-------+-----------------------+----------------------+
| order | 2 | 1 |
+-------+-----------------------+----------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


┌───────┬──────────────────────────┬────────────────────────┐
# 0 1
├───────┼──────────────────────────┼────────────────────────┤
min 15.6789 ms - 202 bytes 2.34568 ms - 102 bytes
max 112.78901 ms - 209 bytes 9.75679 ms - 109 bytes
avg 53.02525 ms - 205 bytes 5.9429 ms - 105 bytes
total 424.20199 ms - 1.61 KB 47.5432 ms - 844 bytes
├───────┼──────────────────────────┼────────────────────────┤
order 2 1
└───────┴──────────────────────────┴────────────────────────┘
+-------+--------------------------+------------------------+
| # | 0 | 1 |
+-------+--------------------------+------------------------+
| min | 15.6789 ms - 202 bytes | 2.34568 ms - 102 bytes |
| max | 112.78901 ms - 209 bytes | 9.75679 ms - 109 bytes |
| avg | 53.02525 ms - 205 bytes | 5.9429 ms - 105 bytes |
| total | 424.20199 ms - 1.61 KB | 47.5432 ms - 844 bytes |
+-------+--------------------------+------------------------+
| order | 2 | 1 |
+-------+--------------------------+------------------------+
Expand Down
Loading