1 | <?php |
||
25 | class HTMLConverter |
||
26 | { |
||
27 | /** |
||
28 | * table class attribute value. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $class_name = 'table-csv-data'; |
||
33 | |||
34 | /** |
||
35 | * table id attribute value. |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $id_value = ''; |
||
40 | |||
41 | /** |
||
42 | * @var XMLConverter |
||
43 | */ |
||
44 | protected $xml_converter; |
||
45 | |||
46 | /** |
||
47 | * New Instance. |
||
48 | */ |
||
49 | 6 | public function __construct() |
|
57 | |||
58 | /** |
||
59 | * Converts a tabular data collection into a HTML table string. |
||
60 | * |
||
61 | * @param array|Traversable $records The tabular data collection |
||
62 | * @param string[] $header_record An optional array of headers outputted using the`<thead>` section |
||
63 | * @param string[] $footer_record An optional array of footers to output to the table using `<tfoot>` and `<th>` elements |
||
64 | */ |
||
65 | 12 | public function convert($records, array $header_record = [], array $footer_record = []): string |
|
85 | |||
86 | /** |
||
87 | * Creates a DOMElement representing a HTML table heading section. |
||
88 | */ |
||
89 | 9 | protected function appendHeaderSection(string $node_name, array $record, DOMElement $table) |
|
109 | |||
110 | /** |
||
111 | * Adds class and id attributes to an HTML tag. |
||
112 | */ |
||
113 | 9 | protected function addHTMLAttributes(DOMElement $node) |
|
118 | |||
119 | /** |
||
120 | * HTML table class name setter. |
||
121 | * |
||
122 | * @throws DOMException if the id_value contains any type of whitespace |
||
123 | */ |
||
124 | 6 | public function table(string $class_name, string $id_value = ''): self |
|
135 | |||
136 | /** |
||
137 | * HTML tr record offset attribute setter. |
||
138 | */ |
||
139 | 3 | public function tr(string $record_offset_attribute_name): self |
|
146 | |||
147 | /** |
||
148 | * HTML td field name attribute setter. |
||
149 | */ |
||
150 | 3 | public function td(string $fieldname_attribute_name): self |
|
157 | } |
||
158 |