Test Failed
Push — develop ( aae594...b21277 )
by Brent
02:43
created

Parsedown::blockFencedCode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Brendt\Stitcher\Lib;
4
5
use \Parsedown as LibParsedown;
6
7
class Parsedown extends LibParsedown
8
{
9
    protected function blockFencedCode($Line)
10
    {
11
        $block = parent::blockFencedCode($Line);
12
13
        if (isset($block['element']['text']['attributes']['class'])) {
14
            $block['element']['attributes']['class'] = $block['element']['text']['attributes']['class'];
15
        }
16
17
        return $block;
18
    }
19
20
    protected function element(array $Element) {
21
        $markup = parent::element($Element);
22
23
        if (!isset($Element['attributes']['href'])) {
24
            return $markup;
25
        }
26
27
        $href = $Element['attributes']['href'];
28
        
29
        if (strpos($href, '*') !== 0) {
30
            return $markup;
31
        }
32
33
        $href = substr($href, 1);
34
        return "<a href='$href' target='_blank' rel='noreferrer noopener'>{$Element['text']}</a>";
35
    }
36
}
37