Passed
Push — render-xml ( 61b7f8 )
by Colin
02:12
created

ThematicBreakRenderer::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <[email protected]>
9
 *
10
 * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
11
 *  - (c) John MacFarlane
12
 *
13
 * For the full copyright and license information, please view the LICENSE
14
 * file that was distributed with this source code.
15
 */
16
17
namespace League\CommonMark\Extension\CommonMark\Renderer\Block;
18
19
use League\CommonMark\Extension\CommonMark\Node\Block\ThematicBreak;
20
use League\CommonMark\Node\Node;
21
use League\CommonMark\Renderer\ChildNodeRendererInterface;
22
use League\CommonMark\Renderer\NodeRendererInterface;
23
use League\CommonMark\Util\HtmlElement;
24
use League\CommonMark\Xml\XmlNodeRendererInterface;
25
26
final class ThematicBreakRenderer implements NodeRendererInterface, XmlNodeRendererInterface
27
{
28
    /**
29
     * @param ThematicBreak $node
30
     *
31
     * {@inheritDoc}
32
     *
33
     * @psalm-suppress MoreSpecificImplementedParamType
34
     */
35 90
    public function render(Node $node, ChildNodeRendererInterface $childRenderer)
36
    {
37 90
        ThematicBreak::assertInstanceOf($node);
38
39 87
        $attrs = $node->data->get('attributes');
40
41 87
        return new HtmlElement('hr', $attrs, '', true);
42
    }
43
44 6
    public function getXmlTagName(Node $node): string
45
    {
46 6
        return 'thematic_break';
47
    }
48
49
    /**
50
     * {@inheritDoc}
51
     */
52 6
    public function getXmlAttributes(Node $node): array
53
    {
54 6
        return [];
55
    }
56
}
57