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

DescriptionListContinueParser   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 7
c 1
b 0
f 0
dl 0
loc 31
ccs 11
cts 11
cp 1
rs 10

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
    /** @var DescriptionList */
28
    private $block;
29
30 30
    public function __construct()
31
    {
32 30
        $this->block = new DescriptionList();
33 30
    }
34
35
    /**
36
     * @return DescriptionList
37
     */
38 30
    public function getBlock(): AbstractBlock
39
    {
40 30
        return $this->block;
41
    }
42
43 27
    public function tryContinue(Cursor $cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue
44
    {
45 27
        return BlockContinue::at($cursor);
46
    }
47
48 30
    public function isContainer(): bool
49
    {
50 30
        return true;
51
    }
52
53 30
    public function canContain(AbstractBlock $childBlock): bool
54
    {
55 30
        return $childBlock instanceof DescriptionTerm || $childBlock instanceof Description;
56
    }
57
}
58