| Conditions | 3 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 34 | public static function load(array $data, ?BlockNode $parent = null): self |
||
| 35 | { |
||
| 36 | self::checkNodeData(static::class, $data, ['attrs']); |
||
| 37 | self::checkRequiredKeys(['level'], $data['attrs']); |
||
| 38 | |||
| 39 | $node = new self($data['attrs']['level'], $parent); |
||
| 40 | |||
| 41 | // set content if defined |
||
| 42 | if (\array_key_exists('content', $data)) { |
||
| 43 | foreach ($data['content'] as $nodeData) { |
||
| 44 | $class = Node::NODE_MAPPING[$nodeData['type']]; |
||
| 45 | $child = $class::load($nodeData, $node); |
||
| 46 | |||
| 47 | $node->append($child); |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | return $node; |
||
| 52 | } |
||
| 62 |