'paragraph', 'text' => $title, ]; $cells = []; $cells[] = self::cellRow($headers, true); foreach ($rows as $row) { $cells[] = self::cellRow($row, false); } $blocks[] = [ 'type' => 'table', 'cells' => $cells, 'is_compact' => $isCompact, 'is_bordered' => true, ]; if ($footer !== null) { $blocks[] = [ 'type' => 'footer', 'text' => $footer, ]; } return [ 'is_rtl' => true, 'blocks' => $blocks, ]; } /** @param string[] $texts */ private static function cellRow(array $texts, bool $isHeader): array { return array_map( static fn(string $t) => [ 'text' => $t, 'is_header' => $isHeader, 'align' => $isHeader ? 'center' : 'right', 'valign' => 'middle', ], $texts ); } }