DescriptionTermContinueParser::parseInlines()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
c 0
b 0
f 0
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