Completed
Push — master ( 0b0b24...54ff37 )
by Colin
02:37
created

BlockQuoteParser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 18 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
 * 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\Extension\CommonMark\Parser\Block;
16
17
use League\CommonMark\Extension\CommonMark\Node\Block\BlockQuote;
18
use League\CommonMark\Parser\Block\BlockParserInterface;
19
use League\CommonMark\Parser\ContextInterface;
20
use League\CommonMark\Parser\Cursor;
21
22
final class BlockQuoteParser implements BlockParserInterface
23
{
24 2487
    public function parse(ContextInterface $context, Cursor $cursor): bool
25
    {
26 2487
        if ($cursor->isIndented()) {
27 183
            return false;
28
        }
29
30 2436
        if ($cursor->getNextNonSpaceCharacter() !== '>') {
31 2424
            return false;
32
        }
33
34 147
        $cursor->advanceToNextNonSpaceOrTab();
35 147
        $cursor->advanceBy(1);
36 147
        $cursor->advanceBySpaceOrTab();
37
38 147
        $context->addBlock(new BlockQuote());
39
40 147
        return true;
41
    }
42
}
43