Completed
Pull Request — master (#13)
by Matthew
01:49
created

StrikeThroughRenderer::render()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 0
cts 11
cp 0
rs 9.4285
cc 3
eloc 7
nc 3
nop 2
crap 12
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
    public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
12
    {
13
        if (!($inline instanceof StrikethroughElement)) {
14
            throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
15
        }
16
17
        $attrs = [];
18
        foreach ($inline->getData('attributes', []) as $key => $value) {
19
            $attrs[$key] = $value;
20
        }
21
        return new HtmlElement('del', $attrs, $inline->getContent());
22
    }
23
}