HeadingParser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getBlock() 0 3 1
A tryContinue() 0 3 1
A parseInlines() 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\CommonMark\Parser\Block;
15
16
use League\CommonMark\Extension\CommonMark\Node\Block\Heading;
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 HeadingParser extends AbstractBlockContinueParser implements BlockContinueParserWithInlinesInterface
26
{
27
    /**
28
     * @var Heading
29
     *
30
     * @psalm-readonly
31
     */
32
    private $block;
33
34
    /** @var string */
35
    private $content;
36
37 231
    public function __construct(int $level, string $content)
38
    {
39 231
        $this->block   = new Heading($level);
40 231
        $this->content = $content;
41 231
    }
42
43 231
    public function getBlock(): AbstractBlock
44
    {
45 231
        return $this->block;
46
    }
47
48 150
    public function tryContinue(Cursor $cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue
49
    {
50 150
        return BlockContinue::none();
51
    }
52
53 231
    public function parseInlines(InlineParserEngineInterface $inlineParser): void
54
    {
55 231
        $inlineParser->parse($this->content, $this->block);
56 231
    }
57
}
58