Completed
Pull Request — master (#18)
by Elan
02:44
created

StrikeThroughRenderer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 12 3
1
<?php
2
3
namespace League\CommonMark\Extras\StrikeThrough;
4
5
use League\CommonMark\ElementRendererInterface;
6
use League\CommonMark\HtmlElement;
7
use League\CommonMark\Inline\Element\AbstractInline;
8
use League\CommonMark\Inline\Renderer\InlineRendererInterface;
9
10
class StrikeThroughRenderer implements InlineRendererInterface {
11 9
    public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
12
    {
13 9
        if (!($inline instanceof StrikethroughElement)) {
14 3
            throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
15
        }
16
17 6
        $attrs = [];
18 6
        foreach ($inline->getData('attributes', []) as $key => $value) {
19 3
            $attrs[$key] = $value;
20 4
        }
21 6
        return new HtmlElement('del', $attrs, $inline->getContent());
22
    }
23
}