@@ -19,7 +19,7 @@ public function show(array $data): void
1919 $ headers = $ this ->headers ($ data );
2020 $ widths = $ this ->columnWidths ($ headers , $ data );
2121
22- $ this ->writeLine ( $ this -> separator ( $ widths) );
22+ $ this ->writeHeaderLine ( $ 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 ->writeLine ( $ this -> separator ( $ widths) );
36+ $ this ->writeFooterLine ( $ widths );
3737 }
3838
3939 protected function headers (array $ data ): array
@@ -54,11 +54,25 @@ protected function columnWidths(array $headers, array $data): array
5454 return $ widths ;
5555 }
5656
57- protected function separator (array $ widths ): string
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
5872 {
59- $ parts = array_map (fn (int $ w ) => str_repeat ('- ' , $ w + 2 ), $ widths );
73+ $ parts = array_map (static fn (int $ w ) => str_repeat ('─ ' , $ w + 2 ), $ widths );
6074
61- return ' + ' . implode (' + ' , $ parts ) . ' + ' ;
75+ return $ start . implode ($ divider , $ parts ) . $ end ;
6276 }
6377
6478 protected function formatRow (array $ values , array $ widths ): string
@@ -69,6 +83,6 @@ protected function formatRow(array $values, array $widths): string
6983 $ cells [] = ' ' . mb_str_pad ((string ) $ value , $ widths [$ i ]) . ' ' ;
7084 }
7185
72- return '| ' . implode ('| ' , $ cells ) . '| ' ;
86+ return '│ ' . implode ('│ ' , $ cells ) . '│ ' ;
7387 }
7488}
0 commit comments