| Total Complexity | 10 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | final class RowCol extends BaseParser implements Parse |
||
| 6 | { |
||
| 7 | public function parse(\DOMElement $node): array |
||
| 8 | { |
||
| 9 | $this->manager->setRowColParentNode($node); |
||
| 10 | $thead = $this->manager->rowColHasHeaders() ? |
||
| 11 | $this->stringifyList($this->collectRowColDefs($node->firstChild)) : []; |
||
| 12 | $tbody = $this->manager->rowColHasHeaders() ? |
||
| 13 | $this->collectRowColRowGroups($node->firstChild) : []; |
||
| 14 | if (\method_exists($tbody, 'count')) { |
||
| 15 | $tbody = 1 === $tbody->count() ? |
||
| 16 | $this->stringifyList($this->collectRows($tbody->item(0)->firstChild)) : $this->stringifyList($tbody); |
||
| 17 | } |
||
| 18 | $tbody = 0 === \count($tbody) ? $this->stringifyList($this->collectRows($node->firstChild)) : $tbody; |
||
| 19 | $thead = 0 === \count($thead) ? \array_shift($tbody) : $thead; |
||
|
|
|||
| 20 | |||
| 21 | return \array_map(function ($row) use ($thead) { |
||
| 22 | return [ |
||
| 23 | 'thead' => $thead, |
||
| 24 | 'tr' => $row, |
||
| 25 | ]; |
||
| 26 | }, $tbody); |
||
| 27 | } |
||
| 28 | |||
| 29 | private function collectRowColDefs(\DOMNode $node): \DOMNodeList |
||
| 30 | { |
||
| 31 | return $this->collect([$this->manager, 'isRowColHeaderSectionNode'], $node, $this->containerDOM()); |
||
| 32 | } |
||
| 33 | |||
| 34 | private function collectRowColRowGroups(\DOMNode $node): \DOMNodeList |
||
| 35 | { |
||
| 36 | return $this->collect([$this->manager, 'isRowColRowGroupNode'], $node, $this->containerDOM()); |
||
| 37 | } |
||
| 38 | |||
| 39 | private function collectRows(\DOMNode $node): \DOMNodeList |
||
| 42 | } |
||
| 43 | } |
||
| 44 |