Completed
Push — latest ( 6c0640...3af091 )
by Colin
16s queued 11s
created

BlockQuoteParser   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
eloc 12
dl 0
loc 43
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getBlock() 0 3 1
A isContainer() 0 3 1
A tryContinue() 0 11 3
A __construct() 0 3 1
A canContain() 0 3 1
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\Extension\CommonMark\Node\Block\BlockQuote;
17
use League\CommonMark\Node\Block\AbstractBlock;
18
use League\CommonMark\Parser\Block\AbstractBlockContinueParser;
19
use League\CommonMark\Parser\Block\BlockContinue;
20
use League\CommonMark\Parser\Block\BlockContinueParserInterface;
21
use League\CommonMark\Parser\Cursor;
22
23
final class BlockQuoteParser extends AbstractBlockContinueParser
24
{
25
    /**
26
     * @var BlockQuote
27
     *
28
     * @psalm-readonly
29
     */
30
    private $block;
31
32 156
    public function __construct()
33
    {
34 156
        $this->block = new BlockQuote();
35 156
    }
36
37
    /**
38
     * @return BlockQuote
39
     */
40 156
    public function getBlock(): AbstractBlock
41
    {
42 156
        return $this->block;
43
    }
44
45 156
    public function isContainer(): bool
46
    {
47 156
        return true;
48
    }
49
50 150
    public function canContain(AbstractBlock $childBlock): bool
51
    {
52 150
        return true;
53
    }
54
55 108
    public function tryContinue(Cursor $cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue
56
    {
57 108
        if (! $cursor->isIndented() && $cursor->getNextNonSpaceCharacter() === '>') {
58 57
            $cursor->advanceToNextNonSpaceOrTab();
59 57
            $cursor->advanceBy(1);
60 57
            $cursor->advanceBySpaceOrTab();
61
62 57
            return BlockContinue::at($cursor);
63
        }
64
65 75
        return BlockContinue::none();
66
    }
67
}
68