Completed
Push — refactor-parsing ( adbb6b...fbe6de )
by Colin
08:21 queued 07:01
created

BlockContinue::getCursorState()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace League\CommonMark\Parser\Block;
13
14
use League\CommonMark\Parser\Cursor;
15
use League\CommonMark\Parser\CursorState;
16
17
/**
18
 * Result object for continuing parsing of a block; see static methods for constructors.
19
 */
20
final class BlockContinue
21
{
22
    /** @var CursorState|null */
23
    private $cursorState;
24
25
    /** @var bool */
26
    private $finalize;
27
28 900
    private function __construct(?CursorState $cursorState = null, bool $finalize = false)
29
    {
30 900
        $this->cursorState = $cursorState;
31 900
        $this->finalize = $finalize;
32 900
    }
33
34 894
    public function getCursorState(): ?CursorState
35
    {
36 894
        return $this->cursorState;
37
    }
38
39 900
    public function isFinalize(): bool
40
    {
41 900
        return $this->finalize;
42
    }
43
44
    /**
45
     * Signal that we cannot continue here
46
     *
47
     * @return null
48
     */
49 825
    public static function none(): ?self
50
    {
51 825
        return null;
52
    }
53
54
    /**
55
     * Signal that we're continuing at the given position
56
     *
57
     * @param Cursor $cursor
58
     *
59
     * @return self
60
     */
61 894
    public static function at(Cursor $cursor): self
62
    {
63 894
        return new self($cursor->saveState(), false);
64
    }
65
66
    /**
67
     * Signal that we want to finalize and close the block
68
     *
69
     * @return self
70
     */
71 87
    public static function finished(): self
72
    {
73 87
        return new self(null, true);
74
    }
75
}
76