LocalLinkNode   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 20
c 1
b 0
f 1
dl 0
loc 35
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toSyntax() 0 3 1
A render() 0 17 1
A resolveLocalLink() 0 8 1
1
<?php
2
3
namespace dokuwiki\plugin\prosemirror\parser;
4
5
class LocalLinkNode extends LinkNode
6
{
7
    public function toSyntax()
8
    {
9
        return $this->getDefaultLinkSyntax($this->attrs['href']);
10
    }
11
12
    public static function render($renderer, $hash, $name)
13
    {
14
        global $ID;
15
16
        $additionalAttributes = [
17
            'data-resolvedTitle' => $ID . ' ↵',
18
            'data-resolvedID' => $ID . '#' . $hash,
19
            'data-resolvedName' => $hash,
20
            'data-resolvedClass' => 'wikilink1',
21
        ];
22
23
        self::renderToJSON(
24
            $renderer,
25
            'internallink',
26
            '#' . $hash,
27
            $name,
28
            $additionalAttributes
29
        );
30
    }
31
32
    public static function resolveLocalLink($hash, $id)
33
    {
34
        $trimmedHash = trim($hash, '#');
35
        return [
36
            'id' => $id . '#' . $trimmedHash,
37
            'exists' => true,
38
            'heading' => $trimmedHash,
39
            'title' => $id . ' ↵',
40
        ];
41
    }
42
}
43