Completed
Push — master ( 6c85d2...15e8d5 )
by Colin
04:57
created

HtmlInlineParser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 6
dl 0
loc 27
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCharacters() 0 4 1
A parse() 0 11 2
1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <[email protected]>
7
 *
8
 * Original code based on the CommonMark JS reference parser (http://bitly.com/commonmark-js)
9
 *  - (c) John MacFarlane
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace League\CommonMark\Inline\Parser;
16
17
use League\CommonMark\Inline\Element\HtmlInline;
18
use League\CommonMark\InlineParserContext;
19
use League\CommonMark\Util\RegexHelper;
20
21
class HtmlInlineParser extends AbstractInlineParser
22
{
23
    /**
24
     * @return string[]
25
     */
26 1872
    public function getCharacters()
27
    {
28 1872
        return ['<'];
29
    }
30
31
    /**
32
     * @param InlineParserContext $inlineContext
33
     *
34
     * @return bool
35
     */
36 120
    public function parse(InlineParserContext $inlineContext)
37
    {
38 120
        $cursor = $inlineContext->getCursor();
39 120
        if ($m = $cursor->match(RegexHelper::getInstance()->getHtmlTagRegex())) {
40 69
            $inlineContext->getContainer()->appendChild(new HtmlInline($m));
41
42 69
            return true;
43
        }
44
45 51
        return false;
46
    }
47
}
48