DescriptionTermContinueParser   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 26
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0
wmc 5

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\Parser\Block\AbstractBlockContinueParser;
18
use League\CommonMark\Parser\Block\BlockContinue;
19
use League\CommonMark\Parser\Block\BlockContinueParserInterface;
20
use League\CommonMark\Parser\Block\BlockContinueParserWithInlinesInterface;
21
use League\CommonMark\Parser\Cursor;
22
use League\CommonMark\Parser\InlineParserEngineInterface;
23
24
final class DescriptionTermContinueParser extends AbstractBlockContinueParser implements BlockContinueParserWithInlinesInterface
25
{
26
    private DescriptionTerm $block;
27
28
    private string $term;
29
30 20
    public function __construct(string $term)
31
    {
32 20
        $this->block = new DescriptionTerm();
33 20
        $this->term  = $term;
34
    }
35
36 20
    public function getBlock(): DescriptionTerm
37
    {
38 20
        return $this->block;
39
    }
40
41
    public function tryContinue(Cursor $cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue
42
    {
43
        return BlockContinue::finished();
44
    }
45
46 20
    public function parseInlines(InlineParserEngineInterface $inlineParser): void
47
    {
48 20
        if ($this->term !== '') {
49 20
            $inlineParser->parse($this->term, $this->block);
50
        }
51
    }
52
}
53