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

Parsedown   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A blockFencedCode() 0 10 2
A element() 0 16 3
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