1 | <?php |
||
12 | class MarkdownTable |
||
13 | { |
||
14 | /** |
||
15 | * @var array |
||
16 | */ |
||
17 | private $headers = []; |
||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | private $rows = []; |
||
22 | /** |
||
23 | * @var \Symfony\Component\Console\Output\OutputInterface |
||
24 | */ |
||
25 | private $output; |
||
26 | /** |
||
27 | * @var int[] |
||
28 | */ |
||
29 | private $columnWidths; |
||
30 | |||
31 | /** |
||
32 | * @param \Symfony\Component\Console\Output\OutputInterface $output |
||
33 | */ |
||
34 | public function __construct(OutputInterface $output) |
||
38 | |||
39 | /** |
||
40 | * Set the column headers. |
||
41 | * |
||
42 | * @param array $headers |
||
43 | * @return $this |
||
44 | */ |
||
45 | public function setHeaders(array $headers) |
||
51 | |||
52 | /** |
||
53 | * Sets all rows, replacing any existing. |
||
54 | * |
||
55 | * @param array $rows |
||
56 | * @return $this |
||
57 | */ |
||
58 | public function setRows(array $rows) |
||
63 | |||
64 | /** |
||
65 | * @param array $rows |
||
66 | * @return $this |
||
67 | */ |
||
68 | public function addRows(array $rows) |
||
75 | |||
76 | /** |
||
77 | * @param \Symfony\Component\Console\Helper\TableSeparator|array $row |
||
78 | * @return $this |
||
79 | */ |
||
80 | public function addRow($row) |
||
93 | |||
94 | /** |
||
95 | * @param int $index |
||
96 | * @param array $row |
||
97 | * @return $this |
||
98 | */ |
||
99 | public function setRow($index, array $row) |
||
104 | |||
105 | /** |
||
106 | * Renders table to output. |
||
107 | */ |
||
108 | public function render() |
||
118 | |||
119 | /** |
||
120 | * Renders a single row. |
||
121 | * |
||
122 | * @param \Symfony\Component\Console\Helper\TableSeparator|array $row |
||
123 | */ |
||
124 | private function renderRow($row) |
||
140 | |||
141 | /** |
||
142 | * Renders the row separator. In this case it should only be used as a header separator. |
||
143 | */ |
||
144 | private function renderRowSeparator() |
||
153 | |||
154 | /** |
||
155 | * Prepare for rendering. |
||
156 | */ |
||
157 | private function prepare() |
||
165 | |||
166 | /** |
||
167 | * Extracts maximum column widths from a row. |
||
168 | * |
||
169 | * @param \Symfony\Component\Console\Helper\TableSeparator|array $row |
||
170 | */ |
||
171 | private function prepareColumnWidths($row) |
||
185 | } |
||
186 |