Passed
Push — dependabot/github_actions/ride... ( bf7823 )
by
unknown
02:50
created

DescriptionTermContinueParser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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