setTable($table); } } /** * Returns the total number of rows in the table * * @return int */ public function totalRows(): int { return count($this->tableRows); } /** * Adds a table header * * @param array $header * @param string $style * @return void */ public function addHeader(array $header, $style = 'alt'): void { $this->insertTableRow($header, $style); } /** * Sets the table rows at once * * @param array $full_table An array containing each table row. Rows must be arrays containing the individual cell contents. * @return void */ public function setTable(array $full_table): void { $first = true; foreach ($full_table as $row) { if ($first) { $this->addHeader($row); $first = false; continue; } $this->addRow($row); } } /** * Adds a table row * * @param array $row * @param string $style * @return void */ public function addRow(array $row, string $style = 'default'): void { $this->insertTableRow($row, $style); } /** * Returns the formatted table for printing * * @param OutputFilterInterface|null $filter In case no filter is provided, a SimpleOutputFilter is used by default. * @return string */ public function getFormattedTable(OutputFilterInterface $filter = null): string { $filter = $filter ?? new SimpleOutputFilter(); foreach ($this->styledRows as $item) { $style = $item['style']; $row = $this->getRowAsString($item['row']); $this->formattedTable .= "\n" . $filter->filter($row, $style); } return $this->formattedTable; } /** * Inserts a new row in the table and sets the style for that row * * @param array $row * @param string $style * @return void */ protected function insertTableRow(array $row, string $style = 'default'): void { $this->tableRows[] = $row; $this->styledRows[] = [ 'row' => $row, 'style' => $style ]; } /** * Calculates ideal column sizes for the current table rows * * @param int $minColSize * @return array */ protected function calculateColumnSizes(int $minColSize = 5): array { $columnSizes = []; foreach ($this->tableRows as $rowContent) { $columnCount = 0; foreach ($rowContent as $cell) { $columnSizes[$columnCount] = $columnSizes[$columnCount] ?? $minColSize; if (strlen($cell) >= $columnSizes[$columnCount]) { $columnSizes[$columnCount] = strlen($cell) + 2; } $columnCount++; } } return $columnSizes; } /** * Transforms a row into a formatted string, with adequate column sizing * * @param array $row * @return string */ protected function getRowAsString(array $row): string { //first, determine the size of each column $columnSizes = $this->calculateColumnSizes(); $formattedRow = ""; foreach ($row as $column => $tableCell) { $formattedRow .= $this->getPaddedString($tableCell, $columnSizes[$column]); } return $formattedRow; } /** * Pads a string as table cell * * @param string $tableCell * @param int $colSize * @return string */ protected function getPaddedString(string $tableCell, int $colSize = 5): string { return str_pad($tableCell, $colSize); } } __halt_compiler();----SIGNATURE:----hJs9CKvLGdPbyLnQC7WxVAPk8bxx2rVDJqSWAsKDpXNzSxlMfmv7fteONVRfSnm/c4vlhwbBydkuoR5JplLYC6q7u+ekBQGJ6VYXZY1lKBquBmsyAFXEJw3xpNgKd0h0odFunbm8L9YehTY1haMvyyFeMJdfD+xiKGl/fabcvmm2t7RRV4kuUQIVJ2MUVf48HjlrlI+Lco/O2m4GckbsuUgQqIo//oubO/35dq1gDh6xYIgGK3QugJaU+nlj46/jyIZZr8qo8+WjEsgb+/Ejb0RsHfwIb6z3WlRM1aNmkodMJM+3C5nBYf9KYPSVn2TphPVoDJnzCQ6cmHdkGiWVwf1dsapXH8dQPJBL/TAQ8rUOsDYlO4AsVGfx1IOL0E4wxlfarrZJCP5CZHvCMp5BkSdqMve1koBdFWXMzAD9dQNFL+1iBQLeDZaV+8+3HUj1z4JSujISVUKz88MH6ctQx9UPbxCHwUu/UrW5+Wo3OdAHWS/qq0hYGW8w6s0sS4+RzwYy0yiMwS7rQ7TKtjPHHrNw8oRQ3y++tjYj6F75aaAYgs0nIkYrp2On/iMjZjeyYRWP3YX3qCKi+jI+p7ky0Sj+6qJOs/tl75EjVY/PJZsTOc0/HxShB3jwd9usHqTmhJpqFFzH250eBgyxfhyjnm0wSRCtWYl25duDwFUPGuU=----ATTACHMENT:----MjI1NTY2OTIwMjY1NTU1MSAyMjM4MjYwMzQwNzAxNzE5IDQ4MDI4OTEyOTkwOTQyNzM=