Passed
Push — master ( c266b5...98a981 )
by Michael
02:18
created

RSSNode::toSyntax()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace dokuwiki\plugin\prosemirror\parser;
4
5
class RSSNode extends Node
6
{
7
8
    protected $parent;
9
    protected $data;
10
11
    public function __construct($data, $parent)
12
    {
13
        $this->parent = &$parent;
14
        $this->data = $data;
15
    }
16
17
    public function toSyntax()
18
    {
19
        $attrs = $this->data['attrs'];
20
        return self::attrToSyntax($attrs);
21
    }
22
23
    protected static function attrToSyntax($attrs) {
24
        $prefix = '{{rss>';
25
        $url = '';
26
        if (!empty($attrs['url'])) {
27
            $url = $attrs['url'];
28
        }
29
        $paramString = '';
30
31
        if (!empty($attrs['max']) && $attrs['max'] !== 8) {
32
            $paramString .= ' ' . $attrs['max'];
33
        }
34
35
        if (!empty($attrs['reverse'])) {
36
            $paramString .= ' reverse';
37
        }
38
39
        if (!empty($attrs['author'])) {
40
            $paramString .= ' author';
41
        }
42
43
        if (!empty($attrs['date'])) {
44
            $paramString .= ' date';
45
        }
46
47
        if (!empty($attrs['details'])) {
48
            $paramString .= ' description';
49
        }
50
51
        if (!empty($attrs['refresh']) && $attrs['refresh'] !== '4h') {
52
            $paramString .= ' ' . $attrs['refresh'];
53
        }
54
        $postfix = '}}';
55
        return $prefix . $url . $paramString . $postfix;
56
    }
57
58
    public static function renderAttrsToHTML($attrs) {
59
        $syntax = self::attrToSyntax($attrs);
60
        dbglog($syntax, __FILE__ . ': ' . __LINE__);
61
        $ins = p_get_instructions($syntax);
62
        return p_render('xhtml', $ins, $info);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $info seems to be never defined.
Loading history...
63
    }
64
}
65