Completed
Push — master ( 7b9015...c5b311 )
by Vladimir
26s queued 11s
created

RstSyntaxBlock::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 5
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
ccs 6
cts 6
cp 1
crap 1
1
<?php
2
3
/**
4
 * @copyright 2018 Vladimir Jimenez
5
 * @license   https://github.com/stakx-io/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\Markup;
9
10
use allejo\stakx\Markup\SyntaxHighlighterTrait;
11
use Gregwar\RST\Directives\CodeBlock;
12
use Gregwar\RST\HTML\Nodes\CodeNode;
13
use Gregwar\RST\Parser;
14
use Highlight\Highlighter;
15
16
class RstSyntaxBlock extends CodeBlock
17
{
18
    use SyntaxHighlighterTrait;
19
20 76
    public function __construct()
21
    {
22 76
        $this->highlighter = new Highlighter();
23 76
    }
24
25 1
    public function process(Parser $parser, $node, $variable, $data, array $options)
26
    {
27
        /* @var CodeNode $node */
28
29 1
        parent::process($parser, $node, $variable, $data, $options);
30
31 1
        $nodeOutput = $this->highlightCode($node->getLanguage(), $node->getValue());
32
33 1
        $node->setRaw(true);
34 1
        $node->setValue($nodeOutput);
35 1
    }
36
}
37