Passed
Push — latest ( 3af091...d64e46 )
by Colin
03:49 queued 01:39
created

DescriptionTermContinueParser   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 9
c 1
b 0
f 0
dl 0
loc 28
ccs 9
cts 11
cp 0.8182
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getBlock() 0 3 1
A parseInlines() 0 4 2
A tryContinue() 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\DescriptionList\Parser;
15
16
use League\CommonMark\Extension\DescriptionList\Node\DescriptionTerm;
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\Block\BlockContinueParserWithInlinesInterface;
22
use League\CommonMark\Parser\Cursor;
23
use League\CommonMark\Parser\InlineParserEngineInterface;
24
25
final class DescriptionTermContinueParser extends AbstractBlockContinueParser implements BlockContinueParserWithInlinesInterface
26
{
27
    /** @var DescriptionTerm */
28
    private $block;
29
30
    /** @var string */
31
    private $term;
32
33 30
    public function __construct(string $term)
34
    {
35 30
        $this->block = new DescriptionTerm();
36 30
        $this->term  = $term;
37 30
    }
38
39 30
    public function getBlock(): AbstractBlock
40
    {
41 30
        return $this->block;
42
    }
43
44
    public function tryContinue(Cursor $cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue
45
    {
46
        return BlockContinue::finished();
47
    }
48
49 30
    public function parseInlines(InlineParserEngineInterface $inlineParser): void
50
    {
51 30
        if ($this->term !== '') {
52 30
            $inlineParser->parse($this->term, $this->block);
53
        }
54 30
    }
55
}
56