IndentedCodeParser   A
last analyzed

Coupling/Cohesion

Components 0
Dependencies 4

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 19 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
 * Original code based on the CommonMark JS reference parser (https://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\Block\Parser;
16
17
use League\CommonMark\Block\Element\IndentedCode;
18
use League\CommonMark\Block\Element\Paragraph;
19
use League\CommonMark\ContextInterface;
20
use League\CommonMark\Cursor;
21
22
class IndentedCodeParser extends AbstractBlockParser
23
{
24
    /**
25
     * @param ContextInterface $context
26
     * @param Cursor           $cursor
27
     *
28
     * @return bool
29
     */
30 1716
    public function parse(ContextInterface $context, Cursor $cursor)
31
    {
32 1716
        if (!$cursor->isIndented()) {
33 1650
            return false;
34
        }
35
36 174
        if ($context->getTip() instanceof Paragraph) {
37 30
            return false;
38
        }
39
40 144
        if ($cursor->isBlank()) {
41 3
            return false;
42
        }
43
44 144
        $cursor->advanceBy(Cursor::INDENT_LEVEL, true);
45 144
        $context->addBlock(new IndentedCode());
46
47 144
        return true;
48
    }
49
}
50