BlockContinue::isFinalize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
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\Parser\Block;
15
16
use League\CommonMark\Parser\Cursor;
17
use League\CommonMark\Parser\CursorState;
18
19
/**
20
 * Result object for continuing parsing of a block; see static methods for constructors.
21
 *
22
 * @psalm-immutable
23
 */
24
final class BlockContinue
25
{
26
    /**
27
     * @var CursorState|null
28
     *
29
     * @psalm-readonly
30
     */
31
    private $cursorState;
32
33
    /**
34
     * @var bool
35
     *
36
     * @psalm-readonly
37
     */
38
    private $finalize;
39
40 999
    private function __construct(?CursorState $cursorState = null, bool $finalize = false)
41
    {
42 999
        $this->cursorState = $cursorState;
43 999
        $this->finalize    = $finalize;
44 999
    }
45
46 993
    public function getCursorState(): ?CursorState
47
    {
48 993
        return $this->cursorState;
49
    }
50
51 999
    public function isFinalize(): bool
52
    {
53 999
        return $this->finalize;
54
    }
55
56
    /**
57
     * Signal that we cannot continue here
58
     *
59
     * @return null
60
     */
61 984
    public static function none(): ?self
62
    {
63 984
        return null;
64
    }
65
66
    /**
67
     * Signal that we're continuing at the given position
68
     */
69 993
    public static function at(Cursor $cursor): self
70
    {
71 993
        return new self($cursor->saveState(), false);
72
    }
73
74
    /**
75
     * Signal that we want to finalize and close the block
76
     */
77 90
    public static function finished(): self
78
    {
79 90
        return new self(null, true);
80
    }
81
}
82