| Conditions | 3 |
| Paths | 2 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | public static function load(array $data, ?BlockNode $parent = null): self |
||
| 19 | { |
||
| 20 | self::checkNodeData(static::class, $data); |
||
| 21 | |||
| 22 | $node = new self( |
||
| 23 | $data['attrs']['background'] ?? null, |
||
| 24 | $data['attrs']['colspan'] ?? null, |
||
| 25 | $data['attrs']['rowspan'] ?? null, |
||
| 26 | $data['attrs']['colwidth'] ?? null, |
||
| 27 | $parent |
||
| 28 | ); |
||
| 29 | |||
| 30 | // set content if defined |
||
| 31 | if (\array_key_exists('content', $data)) { |
||
| 32 | foreach ($data['content'] as $nodeData) { |
||
| 33 | $class = Node::NODE_MAPPING[$nodeData['type']]; |
||
| 34 | $child = $class::load($nodeData, $node); |
||
| 35 | |||
| 36 | $node->append($child); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | return $node; |
||
| 41 | } |
||
| 43 |