1 | <?php |
||
12 | class Table extends Component implements ITable |
||
13 | { |
||
14 | /** |
||
15 | * %1$s - thead - rows |
||
16 | * %2$s - tbody - headers |
||
17 | */ |
||
18 | const TEMPLATE_CONTENT = '%1$s%2$s'; |
||
19 | |||
20 | const TAG_TABLE = 'table'; |
||
21 | const TAG_HEADERS = 'thead'; |
||
22 | const TAG_HEADER_CELL = 'th'; |
||
23 | const TAG_ROWS = 'tbody'; |
||
24 | |||
25 | /** @var Cells */ |
||
26 | protected $headers; |
||
27 | |||
28 | /** @var Rows */ |
||
29 | protected $rows; |
||
30 | |||
31 | /** |
||
32 | * @param Rows $rows |
||
33 | * @param Cells $headers |
||
34 | * @param array $attributes |
||
35 | */ |
||
36 | 5 | public function __construct(Rows $rows, Cells $headers, array $attributes = []) |
|
43 | |||
44 | /** |
||
45 | * @return Cells |
||
46 | */ |
||
47 | public function getHeader(): Cells |
||
51 | |||
52 | /** |
||
53 | * @return Rows |
||
54 | */ |
||
55 | public function getRows(): Rows |
||
59 | |||
60 | /** |
||
61 | * @param int $num |
||
62 | * @param string $whitespace |
||
63 | */ |
||
64 | 2 | public function setIndentation(int $num, string $whitespace = ' ') |
|
65 | { |
||
66 | 2 | foreach ($this->headers as $header) { |
|
67 | 1 | $header->setIndentation($num + 1, $whitespace); |
|
68 | } |
||
69 | |||
70 | 2 | foreach ($this->rows as $row) { |
|
71 | 1 | $row->setIndentation($num + 1, $whitespace); |
|
72 | } |
||
73 | |||
74 | 2 | $this->indentation = str_repeat($whitespace, $num); |
|
75 | 2 | } |
|
76 | |||
77 | /** |
||
78 | * @param ITranslator $translator |
||
79 | */ |
||
80 | 1 | public function setTranslator(ITranslator $translator) |
|
81 | { |
||
82 | 1 | foreach ($this->headers as $header) { |
|
83 | 1 | $header->setTranslator($translator); |
|
84 | } |
||
85 | 1 | } |
|
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | 2 | public function __toString(): string |
|
103 | } |
||
104 |