Completed
Push — refactor-parsing ( adbb6b...fbe6de )
by Colin
08:21 queued 07:01
created

IndentedCodeStartParser   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 21
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A tryStart() 0 18 4
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\Node\Block\Paragraph;
15
use League\CommonMark\Parser\Block\BlockStart;
16
use League\CommonMark\Parser\Block\BlockStartParserInterface;
17
use League\CommonMark\Parser\Cursor;
18
use League\CommonMark\Parser\MarkdownParserStateInterface;
19
20
final class IndentedCodeStartParser implements BlockStartParserInterface
21
{
22 1437
    public function tryStart(Cursor $cursor, MarkdownParserStateInterface $parserState): ?BlockStart
23
    {
24 1437
        if (!$cursor->isIndented()) {
25 1263
            return BlockStart::none();
26
        }
27
28 183
        if ($parserState->getActiveBlockParser()->getBlock() instanceof Paragraph) {
29 33
            return BlockStart::none();
30
        }
31
32 150
        if ($cursor->isBlank()) {
33
            return BlockStart::none();
34
        }
35
36 150
        $cursor->advanceBy(Cursor::INDENT_LEVEL, true);
37
38 150
        return BlockStart::of(new IndentedCodeParser())->at($cursor);
39
    }
40
}
41