Completed
Push — master ( fe5500...ee4a91 )
by Colin
02:11
created

StrikethroughRenderer::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
/*
4
 * This file is part of the league/commonmark-ext-strikethrough package.
5
 *
6
 * (c) Colin O'Dell <[email protected]> and uAfrica.com (http://uafrica.com)
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace League\CommonMark\Ext\Strikethrough;
13
14
use League\CommonMark\ElementRendererInterface;
15
use League\CommonMark\HtmlElement;
16
use League\CommonMark\Inline\Element\AbstractInline;
17
use League\CommonMark\Inline\Renderer\InlineRendererInterface;
18
use League\CommonMark\Util\Xml;
19
20
final class StrikethroughRenderer implements InlineRendererInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25 12
    public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
26
    {
27 12
        if (!($inline instanceof Strikethrough)) {
28 3
            throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
29
        }
30
31 9
        return new HtmlElement('del', $inline->getData('attributes', []), Xml::escape($inline->getContent()));
32
    }
33
}
34