Completed
Push — master ( b4ff9c...fbe6de )
by Colin
01:00
created

ThematicBreakStartParser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 19
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A tryStart() 0 16 3
1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <[email protected]>
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\Extension\CommonMark\Parser\Block;
13
14
use League\CommonMark\Parser\Block\BlockStart;
15
use League\CommonMark\Parser\Block\BlockStartParserInterface;
16
use League\CommonMark\Parser\Cursor;
17
use League\CommonMark\Parser\MarkdownParserStateInterface;
18
use League\CommonMark\Util\RegexHelper;
19
20
final class ThematicBreakStartParser implements BlockStartParserInterface
21
{
22 1692
    public function tryStart(Cursor $cursor, MarkdownParserStateInterface $parserState): ?BlockStart
23
    {
24 1692
        if ($cursor->isIndented()) {
25 183
            return BlockStart::none();
26
        }
27
28 1584
        $match = RegexHelper::matchAt(RegexHelper::REGEX_THEMATIC_BREAK, $cursor->getLine(), $cursor->getNextNonSpacePosition());
29 1584
        if ($match === null) {
30 1521
            return BlockStart::none();
31
        }
32
33
        // Advance to the end of the string, consuming the entire line (of the thematic break)
34 87
        $cursor->advanceToEnd();
35
36 87
        return BlockStart::of(new ThematicBreakParser())->at($cursor);
37
    }
38
}
39