Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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 <colinodell@gmail.com>
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\Parser;
15
 
16
use League\CommonMark\Parser\Block\BlockContinueParserInterface;
17
use League\CommonMark\Parser\Block\ParagraphParser;
18
 
19
/**
20
 * @internal You should rely on the interface instead
21
 */
22
final class MarkdownParserState implements MarkdownParserStateInterface
23
{
24
    /** @psalm-readonly */
25
    private BlockContinueParserInterface $activeBlockParser;
26
 
27
    /** @psalm-readonly */
28
    private BlockContinueParserInterface $lastMatchedBlockParser;
29
 
30
    public function __construct(BlockContinueParserInterface $activeBlockParser, BlockContinueParserInterface $lastMatchedBlockParser)
31
    {
32
        $this->activeBlockParser      = $activeBlockParser;
33
        $this->lastMatchedBlockParser = $lastMatchedBlockParser;
34
    }
35
 
36
    public function getActiveBlockParser(): BlockContinueParserInterface
37
    {
38
        return $this->activeBlockParser;
39
    }
40
 
41
    public function getLastMatchedBlockParser(): BlockContinueParserInterface
42
    {
43
        return $this->lastMatchedBlockParser;
44
    }
45
 
46
    public function getParagraphContent(): ?string
47
    {
48
        if (! $this->lastMatchedBlockParser instanceof ParagraphParser) {
49
            return null;
50
        }
51
 
52
        $paragraphParser = $this->lastMatchedBlockParser;
53
        $content         = $paragraphParser->getContentString();
54
 
55
        return $content === '' ? null : $content;
56
    }
57
}