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
|
|
|
* Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js) |
11
|
|
|
* - (c) John MacFarlane |
12
|
|
|
* |
13
|
|
|
* For the full copyright and license information, please view the LICENSE |
14
|
|
|
* file that was distributed with this source code. |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace League\CommonMark\Delimiter; |
18
|
|
|
|
19
|
|
|
use League\CommonMark\Node\Inline\AbstractStringContainer; |
20
|
|
|
|
21
|
|
|
final class Delimiter implements DelimiterInterface |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
* |
26
|
|
|
* @psalm-readonly |
27
|
|
|
*/ |
28
|
|
|
private $char; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var int |
32
|
|
|
* |
33
|
|
|
* @psalm-readonly-allow-private-mutation |
34
|
|
|
*/ |
35
|
|
|
private $length; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var int |
39
|
|
|
* |
40
|
|
|
* @psalm-readonly |
41
|
|
|
*/ |
42
|
|
|
private $originalLength; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var AbstractStringContainer |
46
|
|
|
* |
47
|
|
|
* @psalm-readonly |
48
|
|
|
*/ |
49
|
|
|
private $inlineNode; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var DelimiterInterface|null |
53
|
|
|
* |
54
|
|
|
* @psalm-readonly-allow-private-mutation |
55
|
|
|
*/ |
56
|
|
|
private $previous; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var DelimiterInterface|null |
60
|
|
|
* |
61
|
|
|
* @psalm-readonly-allow-private-mutation |
62
|
|
|
*/ |
63
|
|
|
private $next; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @var bool |
67
|
|
|
* |
68
|
|
|
* @psalm-readonly |
69
|
|
|
*/ |
70
|
|
|
private $canOpen; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @var bool |
74
|
|
|
* |
75
|
|
|
* @psalm-readonly |
76
|
|
|
*/ |
77
|
|
|
private $canClose; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @var bool |
81
|
|
|
* |
82
|
|
|
* @psalm-readonly-allow-private-mutation |
83
|
|
|
*/ |
84
|
|
|
private $active; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var int|null |
88
|
|
|
* |
89
|
|
|
* @psalm-readonly |
90
|
|
|
*/ |
91
|
|
|
private $index; |
92
|
|
|
|
93
|
1131 |
|
public function __construct(string $char, int $numDelims, AbstractStringContainer $node, bool $canOpen, bool $canClose, ?int $index = null) |
94
|
|
|
{ |
95
|
1131 |
|
$this->char = $char; |
96
|
1131 |
|
$this->length = $numDelims; |
97
|
1131 |
|
$this->originalLength = $numDelims; |
98
|
1131 |
|
$this->inlineNode = $node; |
99
|
1131 |
|
$this->canOpen = $canOpen; |
100
|
1131 |
|
$this->canClose = $canClose; |
101
|
1131 |
|
$this->active = true; |
102
|
1131 |
|
$this->index = $index; |
103
|
1131 |
|
} |
104
|
|
|
|
105
|
1035 |
|
public function canClose(): bool |
106
|
|
|
{ |
107
|
1035 |
|
return $this->canClose; |
108
|
|
|
} |
109
|
|
|
|
110
|
633 |
|
public function canOpen(): bool |
111
|
|
|
{ |
112
|
633 |
|
return $this->canOpen; |
113
|
|
|
} |
114
|
|
|
|
115
|
504 |
|
public function isActive(): bool |
116
|
|
|
{ |
117
|
504 |
|
return $this->active; |
118
|
|
|
} |
119
|
|
|
|
120
|
27 |
|
public function setActive(bool $active): void |
121
|
|
|
{ |
122
|
27 |
|
$this->active = $active; |
123
|
27 |
|
} |
124
|
|
|
|
125
|
1119 |
|
public function getChar(): string |
126
|
|
|
{ |
127
|
1119 |
|
return $this->char; |
128
|
|
|
} |
129
|
|
|
|
130
|
306 |
|
public function getIndex(): ?int |
131
|
|
|
{ |
132
|
306 |
|
return $this->index; |
133
|
|
|
} |
134
|
|
|
|
135
|
1119 |
|
public function getNext(): ?DelimiterInterface |
136
|
|
|
{ |
137
|
1119 |
|
return $this->next; |
138
|
|
|
} |
139
|
|
|
|
140
|
639 |
|
public function setNext(?DelimiterInterface $next): void |
141
|
|
|
{ |
142
|
639 |
|
$this->next = $next; |
143
|
639 |
|
} |
144
|
|
|
|
145
|
537 |
|
public function getLength(): int |
146
|
|
|
{ |
147
|
537 |
|
return $this->length; |
148
|
|
|
} |
149
|
|
|
|
150
|
528 |
|
public function setLength(int $length): void |
151
|
|
|
{ |
152
|
528 |
|
$this->length = $length; |
153
|
528 |
|
} |
154
|
|
|
|
155
|
72 |
|
public function getOriginalLength(): int |
156
|
|
|
{ |
157
|
72 |
|
return $this->originalLength; |
158
|
|
|
} |
159
|
|
|
|
160
|
855 |
|
public function getInlineNode(): AbstractStringContainer |
161
|
|
|
{ |
162
|
855 |
|
return $this->inlineNode; |
163
|
|
|
} |
164
|
|
|
|
165
|
1119 |
|
public function getPrevious(): ?DelimiterInterface |
166
|
|
|
{ |
167
|
1119 |
|
return $this->previous; |
168
|
|
|
} |
169
|
|
|
|
170
|
1119 |
|
public function setPrevious(?DelimiterInterface $previous): void |
171
|
|
|
{ |
172
|
1119 |
|
$this->previous = $previous; |
173
|
1119 |
|
} |
174
|
|
|
} |
175
|
|
|
|