| Total Complexity | 8 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class ListItemNode extends Node |
||
| 13 | { |
||
| 14 | protected $parent; |
||
| 15 | /** @var Node[] */ |
||
| 16 | protected $subnodes = []; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * ListItemNode constructor. |
||
| 20 | * |
||
| 21 | * @param $data |
||
| 22 | * @param ListNode $parent |
||
| 23 | */ |
||
| 24 | public function __construct($data, Node $parent) |
||
| 25 | { |
||
| 26 | $this->parent = &$parent; |
||
| 27 | |||
| 28 | foreach ($data['content'] as $node) { |
||
| 29 | if ($node['type'] === 'list_content') { |
||
| 30 | foreach ($node['content'] as $subnode) { |
||
| 31 | $this->subnodes[] = self::getSubNode($subnode, $this); |
||
| 32 | } |
||
| 33 | continue; |
||
| 34 | } |
||
| 35 | |||
| 36 | $this->subnodes[] = self::getSubNode($node, $this); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | public function toSyntax() |
||
| 41 | { |
||
| 42 | $lines = []; |
||
| 43 | foreach ($this->subnodes as $node) { |
||
| 44 | /* |
||
| 45 | * only sublists may start with a linebreak, other blocks, like <code> must not have a linebreak before them |
||
| 46 | * or DokuWiki will interprete this as a new block altogether, instead as something that is part of the |
||
| 47 | * current <li> |
||
| 48 | */ |
||
| 49 | $prefixLinebreak = ''; |
||
| 50 | if ($node instanceof ListNode) { |
||
| 51 | $prefixLinebreak = "\n"; |
||
| 52 | } |
||
| 53 | $lines[] = $prefixLinebreak . $node->toSyntax(); |
||
| 54 | } |
||
| 55 | return implode("", $lines); |
||
| 56 | } |
||
| 57 | |||
| 58 | public function getDepth() |
||
| 61 | } |
||
| 62 | } |
||
| 63 |