Completed
Push — master ( 00045a...da0d4f )
by Colin
02:22
created

Delimiter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 10
cts 10
cp 1
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 6
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
 * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
9
 *  - (c) John MacFarlane
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace League\CommonMark\Delimiter;
16
17
use League\CommonMark\Node\Node;
18
19
class Delimiter
20
{
21
    /** @var string */
22
    protected $char;
23
24
    /** @var int */
25
    protected $numDelims;
26
27
    /** @var int */
28
    protected $origDelims;
29
30
    /** @var Node */
31
    protected $inlineNode;
32
33
    /** @var Delimiter|null */
34
    protected $previous;
35
36
    /** @var Delimiter|null */
37
    protected $next;
38
39
    /** @var bool */
40
    protected $canOpen;
41
42
    /** @var bool */
43
    protected $canClose;
44
45
    /** @var bool */
46
    protected $active;
47
48
    /** @var int|null */
49
    protected $index;
50
51
    /**
52
     * @param string   $char
53
     * @param int      $numDelims
54
     * @param Node     $node
55
     * @param bool     $canOpen
56
     * @param bool     $canClose
57
     * @param int|null $index
58
     */
59 942
    public function __construct(string $char, int $numDelims, Node $node, bool $canOpen, bool $canClose, ?int $index = null)
60
    {
61 942
        $this->char = $char;
62 942
        $this->numDelims = $numDelims;
63 942
        $this->origDelims = $numDelims;
64 942
        $this->inlineNode = $node;
65 942
        $this->canOpen = $canOpen;
66 942
        $this->canClose = $canClose;
67 942
        $this->active = true;
68 942
        $this->index = $index;
69 942
    }
70
71
    /**
72
     * @return bool
73
     */
74 846
    public function canClose(): bool
75
    {
76 846
        return $this->canClose;
77
    }
78
79
    /**
80
     * @param bool $canClose
81
     *
82
     * @return $this
83
     */
84 3
    public function setCanClose(bool $canClose)
85
    {
86 3
        $this->canClose = $canClose;
87
88 3
        return $this;
89
    }
90
91
    /**
92
     * @return bool
93
     */
94 429
    public function canOpen(): bool
95
    {
96 429
        return $this->canOpen;
97
    }
98
99
    /**
100
     * @param bool $canOpen
101
     *
102
     * @return $this
103
     */
104 3
    public function setCanOpen(bool $canOpen)
105
    {
106 3
        $this->canOpen = $canOpen;
107
108 3
        return $this;
109
    }
110
111
    /**
112
     * @return bool
113
     */
114 432
    public function isActive(): bool
115
    {
116 432
        return $this->active;
117
    }
118
119
    /**
120
     * @param bool $active
121
     *
122
     * @return $this
123
     */
124 27
    public function setActive(bool $active)
125
    {
126 27
        $this->active = $active;
127
128 27
        return $this;
129
    }
130
131
    /**
132
     * @return string
133
     */
134 918
    public function getChar(): string
135
    {
136 918
        return $this->char;
137
    }
138
139
    /**
140
     * @param string $char
141
     *
142
     * @return $this
143
     */
144 3
    public function setChar(string $char)
145
    {
146 3
        $this->char = $char;
147
148 3
        return $this;
149
    }
150
151
    /**
152
     * @return int|null
153
     */
154 240
    public function getIndex(): ?int
155
    {
156 240
        return $this->index;
157
    }
158
159
    /**
160
     * @param int|null $index
161
     *
162
     * @return $this
163
     */
164 3
    public function setIndex(?int $index)
165
    {
166 3
        $this->index = $index;
167
168 3
        return $this;
169
    }
170
171
    /**
172
     * @return Delimiter|null
173
     */
174 915
    public function getNext(): ?self
175
    {
176 915
        return $this->next;
177
    }
178
179
    /**
180
     * @param Delimiter|null $next
181
     *
182
     * @return $this
183
     */
184 525
    public function setNext(?self $next)
185
    {
186 525
        $this->next = $next;
187
188 525
        return $this;
189
    }
190
191
    /**
192
     * @return int
193
     */
194 357
    public function getNumDelims(): int
195
    {
196 357
        return $this->numDelims;
197
    }
198
199
    /**
200
     * @param int $numDelims
201
     *
202
     * @return $this
203
     */
204 354
    public function setNumDelims(int $numDelims)
205
    {
206 354
        $this->numDelims = $numDelims;
207
208 354
        return $this;
209
    }
210
211
    /**
212
     * @return int
213
     */
214 81
    public function getOrigDelims(): int
215
    {
216 81
        return $this->origDelims;
217
    }
218
219
    /**
220
     * @return Node
221
     */
222 660
    public function getInlineNode(): Node
223
    {
224 660
        return $this->inlineNode;
225
    }
226
227
    /**
228
     * @param Node $node
229
     *
230
     * @return $this
231
     */
232 3
    public function setInlineNode(Node $node)
233
    {
234 3
        $this->inlineNode = $node;
235
236 3
        return $this;
237
    }
238
239
    /**
240
     * @return Delimiter|null
241
     */
242 915
    public function getPrevious(): ?self
243
    {
244 915
        return $this->previous;
245
    }
246
247
    /**
248
     * @param Delimiter|null $previous
249
     *
250
     * @return $this
251
     */
252 915
    public function setPrevious(?self $previous)
253
    {
254 915
        $this->previous = $previous;
255
256 915
        return $this;
257
    }
258
}
259