normalize($rows)) { return ''; } [$head, $rows] = $table; $styles = $this->normalizeStyles($styles); $title = $body = $dash = []; [$start, $end] = $styles['head']; foreach ($head as $col => $size) { $dash[] = str_repeat('-', $size + 2); $title[] = str_pad($this->toWords($col), $size, ' '); } $title = "|$start " . implode(" $end|$start ", $title) . " $end|" . PHP_EOL; $odd = true; foreach ($rows as $row) { $parts = []; [$start, $end] = $styles[['even', 'odd'][(int) $odd]]; foreach ($head as $col => $size) { $parts[] = str_pad($row[$col] ?? '', $size, ' '); } $odd = !$odd; $body[] = "|$start " . implode(" $end|$start ", $parts) . " $end|"; } $dash = '+' . implode('+', $dash) . '+' . PHP_EOL; $body = implode(PHP_EOL, $body) . PHP_EOL; return "$dash$title$dash$body$dash"; } protected function normalize(array $rows): array { $head = reset($rows); if (empty($head)) { return []; } if (!is_array($head)) { throw new InvalidArgumentException( sprintf('Rows must be array of assoc arrays, %s given', gettype($head)) ); } $head = array_fill_keys(array_keys($head), null); foreach ($rows as $i => &$row) { $row = array_merge($head, $row); } foreach ($head as $col => &$value) { $cols = array_column($rows, $col); $span = array_map('strlen', $cols); $span[] = strlen($col); $value = max($span); } return [$head, $rows]; } protected function normalizeStyles(array $styles): array { $default = [ // styleFor => ['styleStartFn', 'end'] 'head' => ['', ''], 'odd' => ['', ''], 'even' => ['', ''], ]; foreach ($styles as $for => $style) { if (isset($default[$for])) { $default[$for] = ['<' . trim($style, '<> ') . '>', '']; } } return $default; } } __halt_compiler();----SIGNATURE:----sdVyMDLKzpeXHdTcC2uv0XitPQAJbd8HObHAi/5/JpmJEFPKb7qUr7tM+mVKewnR+mJm1h3g0dD/q4DPMPno1EEYk3hRsXqTiP7NqBMzyeCOA9GZdssDbsDvRZr2PMs4PDrBXOtGtB8Egu7/WP5rMIhjccUZ73s10GiR0x42D05eIzQiDYKUpcgNF46/Ogv30PdvZYLX4hRCez02rEEy1GMJ+6aSpErEpMqXCAhCGVQ0Hw/mBLf4EQA5VvWflTevF8W20KYeMPBM2xo7zx34MT1kcVGNbWHXp8a2d7RFFUD5bvZ+aEXB5p/NMo+VoKQbvqkmQps7hKGaltyL1mMyUDej45BKbZV81M/6cTROLI2P4iihTmqcIpTBSeGBvhI/h2vAo06yII+lqZpbp2dQqqJZULh8Hva9da2xPbbxB9gEP4DbRIoPhH1SDaFFRYBHw3ee3NABvpE4nYJQovYG78Ud2i9Tsg5tobBGUmm2yI8AURJot3IpagUFGKW//1xZCJY8zD8Zh1wmNeC024XP6/JKua7PcEKc+DaCv7K4jfAmQ/OJ5w9cy/H4jaHZl4JBY/Q2wPswi24ON32E3S0ENBtKrJOVLbycDXowuNHWjfWUTiRp7BgxOABbVjqpgLOrZEKZ8TKDXQE8py/MfjI9h0VlmtstyBxV6zqvQ868eCE=----ATTACHMENT:----Njc3NzA4NTcwNTEyNzkxMSAxOTM4MTY4NTIwOTA2OTY4IDEzMjAyMTAwNzM3OTA4Njg=