FootnoteNode::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 5
c 1
b 0
f 1
nc 2
nop 2
dl 0
loc 7
rs 10
1
<?php
2
3
namespace dokuwiki\plugin\prosemirror\parser;
4
5
class FootnoteNode extends Node
6
{
7
    /** @var TextNode[] */
8
    protected $subnodes = [];
9
10
    protected $parent;
11
12
    public function __construct($data, Node $parent)
13
    {
14
        $this->parent = &$parent;
15
        $json = $data['attrs']['contentJSON'];
16
        $contentDoc = json_decode($json, true);
17
        foreach ($contentDoc['content'] as $subnode) {
18
            $this->subnodes[] = self::getSubNode($subnode, $this);
19
        }
20
    }
21
22
    public function toSyntax()
23
    {
24
        $doc = '';
25
        foreach ($this->subnodes as $subnode) {
26
            $doc .= $subnode->toSyntax() . "\n\n";
27
        }
28
        return "((\n" . rtrim(ltrim($doc, "\n")) . "\n))";
29
    }
30
}
31