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

BlockQuoteParser::parse()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 9.6666
c 0
b 0
f 0
cc 3
nc 3
nop 2
crap 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