1 | <?php |
||
23 | class Table |
||
24 | { |
||
25 | const SPINNER = "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"; |
||
26 | |||
27 | /** @var Pool */ |
||
28 | private $processPool; |
||
29 | /** @var string[] */ |
||
30 | private $rows = []; |
||
31 | /** @var Exception[] */ |
||
32 | private $exceptions; |
||
33 | /** @var int[] */ |
||
34 | private $maxLengths = []; |
||
35 | /** @var DiffConsoleOutput */ |
||
36 | private $output; |
||
37 | /** @var TerminalInterface */ |
||
38 | private $terminal; |
||
39 | /** @var bool */ |
||
40 | private $showOutput = true; |
||
41 | /** @var bool */ |
||
42 | private $showSummary = true; |
||
43 | |||
44 | /** |
||
45 | * Table constructor. |
||
46 | * |
||
47 | * @param OutputInterface $output |
||
48 | * @param Pool|null $pool |
||
49 | */ |
||
50 | public function __construct(OutputInterface $output, Pool $pool = null) |
||
62 | |||
63 | /** |
||
64 | * Parses the rows to determine the key lengths to make a pretty table |
||
65 | * |
||
66 | * @param array $data |
||
67 | */ |
||
68 | private function updateRowKeyLengths(array $data = []) |
||
82 | |||
83 | /** |
||
84 | * @param array $data |
||
85 | * @param string $status |
||
86 | * @param float $duration |
||
87 | * @param string $extra |
||
88 | * |
||
89 | * @return string |
||
90 | */ |
||
91 | private function formatRow(array $data, $status, $duration, $extra = '') |
||
101 | |||
102 | /** |
||
103 | * @param Process $process |
||
104 | * @param array $data |
||
105 | */ |
||
106 | public function add(Process $process, array $data = []) |
||
145 | |||
146 | /** |
||
147 | * @return string |
||
148 | */ |
||
149 | private function getSummary() |
||
166 | |||
167 | /** |
||
168 | * Render a specific row |
||
169 | * |
||
170 | * @param int $row |
||
171 | */ |
||
172 | private function render($row = 0) |
||
181 | |||
182 | /** |
||
183 | * @param float $checkInterval |
||
184 | * |
||
185 | * @return bool true if all processes were successful |
||
186 | * @throws Exception |
||
187 | */ |
||
188 | public function run($checkInterval = Pool::CHECK_INTERVAL) |
||
208 | |||
209 | /** |
||
210 | * @return bool |
||
211 | */ |
||
212 | public function isShowOutput() |
||
216 | |||
217 | /** |
||
218 | * @param bool $showOutput |
||
219 | * |
||
220 | * @return $this |
||
221 | */ |
||
222 | public function setShowOutput($showOutput) |
||
227 | |||
228 | /** |
||
229 | * @return bool |
||
230 | */ |
||
231 | public function isShowSummary() |
||
235 | |||
236 | /** |
||
237 | * @param bool $showSummary |
||
238 | * |
||
239 | * @return $this |
||
240 | */ |
||
241 | public function setShowSummary($showSummary) |
||
246 | } |
||
247 |