DescriptionListContinueParser   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A canContain() 0 3 2
A __construct() 0 3 1
A tryContinue() 0 3 1
A getBlock() 0 3 1
A isContainer() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace League\CommonMark\Extension\DescriptionList\Parser;
15
16
use League\CommonMark\Extension\DescriptionList\Node\Description;
17
use League\CommonMark\Extension\DescriptionList\Node\DescriptionList;
18
use League\CommonMark\Extension\DescriptionList\Node\DescriptionTerm;
19
use League\CommonMark\Node\Block\AbstractBlock;
20
use League\CommonMark\Parser\Block\AbstractBlockContinueParser;
21
use League\CommonMark\Parser\Block\BlockContinue;
22
use League\CommonMark\Parser\Block\BlockContinueParserInterface;
23
use League\CommonMark\Parser\Cursor;
24
25
final class DescriptionListContinueParser extends AbstractBlockContinueParser
26
{
27
    private DescriptionList $block;
28
29
    public function __construct()
30
    {
31
        $this->block = new DescriptionList();
32
    }
33
34
    public function getBlock(): DescriptionList
35
    {
36
        return $this->block;
37
    }
38
39
    public function tryContinue(Cursor $cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue
40
    {
41
        return BlockContinue::at($cursor);
42
    }
43
44
    public function isContainer(): bool
45
    {
46
        return true;
47
    }
48
49
    public function canContain(AbstractBlock $childBlock): bool
50
    {
51
        return $childBlock instanceof DescriptionTerm || $childBlock instanceof Description;
52
    }
53
}
54