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

RstSyntaxBlock   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 21
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A process() 0 11 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