Passed
Push — main ( 989696...2152d5 )
by Colin
05:14 queued 02:09
created

HtmlInlineRenderer::getXmlAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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\Inline;
18
19
use League\CommonMark\Extension\CommonMark\Node\Inline\HtmlInline;
20
use League\CommonMark\Node\Node;
21
use League\CommonMark\Renderer\ChildNodeRendererInterface;
22
use League\CommonMark\Renderer\NodeRendererInterface;
23
use League\CommonMark\Util\HtmlFilter;
24
use League\CommonMark\Xml\XmlNodeRendererInterface;
25
use League\Config\ConfigurationAwareInterface;
26
use League\Config\ConfigurationInterface;
27
28
final class HtmlInlineRenderer implements NodeRendererInterface, XmlNodeRendererInterface, ConfigurationAwareInterface
29
{
30
    /**
31
     * @var ConfigurationInterface
32
     *
33
     * @psalm-readonly-allow-private-mutation
34
     */
35
    private $config;
36
37
    /**
38
     * @param HtmlInline $node
39
     *
40
     * {@inheritDoc}
41
     *
42
     * @psalm-suppress MoreSpecificImplementedParamType
43
     */
44 108
    public function render(Node $node, ChildNodeRendererInterface $childRenderer)
45
    {
46 108
        HtmlInline::assertInstanceOf($node);
47
48 105
        $htmlInput = $this->config->get('html_input');
49
50 105
        return HtmlFilter::filter($node->getLiteral(), $htmlInput);
51
    }
52
53 3084
    public function setConfiguration(ConfigurationInterface $configuration): void
54
    {
55 3084
        $this->config = $configuration;
56 3084
    }
57
58 3
    public function getXmlTagName(Node $node): string
59
    {
60 3
        return 'html_inline';
61
    }
62
63
    /**
64
     * {@inheritDoc}
65
     */
66 3
    public function getXmlAttributes(Node $node): array
67
    {
68 3
        return [];
69
    }
70
}
71