IndentedCodeStartParser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
dl 0
loc 19
ccs 8
cts 9
cp 0.8889
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A tryStart() 0 17 4
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
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace League\CommonMark\Extension\CommonMark\Parser\Block;
15
16
use League\CommonMark\Node\Block\Paragraph;
17
use League\CommonMark\Parser\Block\BlockStart;
18
use League\CommonMark\Parser\Block\BlockStartParserInterface;
19
use League\CommonMark\Parser\Cursor;
20
use League\CommonMark\Parser\MarkdownParserStateInterface;
21
22
final class IndentedCodeStartParser implements BlockStartParserInterface
23
{
24 1542
    public function tryStart(Cursor $cursor, MarkdownParserStateInterface $parserState): ?BlockStart
25
    {
26 1542
        if (! $cursor->isIndented()) {
27 1356
            return BlockStart::none();
28
        }
29
30 195
        if ($parserState->getActiveBlockParser()->getBlock() instanceof Paragraph) {
31 39
            return BlockStart::none();
32
        }
33
34 156
        if ($cursor->isBlank()) {
35
            return BlockStart::none();
36
        }
37
38 156
        $cursor->advanceBy(Cursor::INDENT_LEVEL, true);
39
40 156
        return BlockStart::of(new IndentedCodeParser())->at($cursor);
41
    }
42
}
43