HtmlInlineParser::parse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
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\Parser\Inline;
18
19
use League\CommonMark\Extension\CommonMark\Node\Inline\HtmlInline;
20
use League\CommonMark\Parser\Inline\InlineParserInterface;
21
use League\CommonMark\Parser\Inline\InlineParserMatch;
22
use League\CommonMark\Parser\InlineParserContext;
23
use League\CommonMark\Util\RegexHelper;
24
25
final class HtmlInlineParser implements InlineParserInterface
26
{
27 2982
    public function getMatchDefinition(): InlineParserMatch
28
    {
29 2982
        return InlineParserMatch::regex(RegexHelper::PARTIAL_HTMLTAG);
30
    }
31
32 93
    public function parse(InlineParserContext $inlineContext): bool
33
    {
34 93
        $inline = $inlineContext->getFullMatch();
35
36 93
        $inlineContext->getCursor()->advanceBy($inlineContext->getFullMatchLength());
37 93
        $inlineContext->getContainer()->appendChild(new HtmlInline($inline));
38
39 93
        return true;
40
    }
41
}
42