CursorState   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A toArray() 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\Parser;
15
16
/**
17
 * Encapsulates the current state of a cursor in case you need to rollback later.
18
 *
19
 * WARNING: Do not attempt to use this class for ANYTHING except for
20
 * type hinting and passing this object back into restoreState().
21
 * The constructor, methods, and inner contents may change in any
22
 * future release without warning!
23
 *
24
 * @internal
25
 *
26
 * @psalm-immutable
27
 */
28
final class CursorState
29
{
30
    /**
31
     * @var array<int, mixed>
32
     *
33
     * @psalm-readonly
34
     */
35
    private $state;
36
37
    /**
38
     * @internal
39
     *
40
     * @param array<int, mixed> $state
41
     */
42 1980
    public function __construct(array $state)
43
    {
44 1980
        $this->state = $state;
45 1980
    }
46
47
    /**
48
     * @internal
49
     *
50
     * @return array<int, mixed>
51
     */
52 1809
    public function toArray(): array
53
    {
54 1809
        return $this->state;
55
    }
56
}
57