Completed
Push — master ( 33e779...8dfaf9 )
by Colin
20s
created

Delimiter::getLength()   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
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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\Inline\Element\AbstractStringContainer;
18
19
final class Delimiter implements DelimiterInterface
20
{
21
    /** @var string */
22
    private $char;
23
24
    /** @var int */
25
    private $length;
26
27
    /** @var int */
28
    private $originalLength;
29
30
    /** @var AbstractStringContainer */
31
    private $inlineNode;
32
33
    /** @var DelimiterInterface|null */
34
    private $previous;
35
36
    /** @var DelimiterInterface|null */
37
    private $next;
38
39
    /** @var bool */
40
    private $canOpen;
41
42
    /** @var bool */
43
    private $canClose;
44
45
    /** @var bool */
46
    private $active;
47
48
    /** @var int|null */
49
    private $index;
50
51
    /**
52
     * @param string                  $char
53
     * @param int                     $numDelims
54
     * @param AbstractStringContainer $node
55
     * @param bool                    $canOpen
56
     * @param bool                    $canClose
57
     * @param int|null                $index
58
     */
59 1008
    public function __construct(string $char, int $numDelims, AbstractStringContainer $node, bool $canOpen, bool $canClose, ?int $index = null)
60
    {
61 1008
        $this->char = $char;
62 1008
        $this->length = $numDelims;
63 1008
        $this->originalLength = $numDelims;
64 1008
        $this->inlineNode = $node;
65 1008
        $this->canOpen = $canOpen;
66 1008
        $this->canClose = $canClose;
67 1008
        $this->active = true;
68 1008
        $this->index = $index;
69 1008
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74 924
    public function canClose(): bool
75
    {
76 924
        return $this->canClose;
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82 3
    public function setCanClose(bool $canClose)
83
    {
84 3
        $this->canClose = $canClose;
85 3
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90 498
    public function canOpen(): bool
91
    {
92 498
        return $this->canOpen;
93
    }
94
95
    /**
96
     * {@inheritdoc}
97
     */
98 426
    public function isActive(): bool
99
    {
100 426
        return $this->active;
101
    }
102
103
    /**
104
     * {@inheritdoc}
105
     */
106 27
    public function setActive(bool $active)
107
    {
108 27
        $this->active = $active;
109 27
    }
110
111
    /**
112
     * {@inheritdoc}
113
     */
114 993
    public function getChar(): string
115
    {
116 993
        return $this->char;
117
    }
118
119
    /**
120
     * {@inheritdoc}
121
     */
122 288
    public function getIndex(): ?int
123
    {
124 288
        return $this->index;
125
    }
126
127
    /**
128
     * {@inheritdoc}
129
     */
130 993
    public function getNext(): ?DelimiterInterface
131
    {
132 993
        return $this->next;
133
    }
134
135
    /**
136
     * {@inheritdoc}
137
     */
138 600
    public function setNext(?DelimiterInterface $next)
139
    {
140 600
        $this->next = $next;
141 600
    }
142
143
    /**
144
     * {@inheritdoc}
145
     */
146 420
    public function getLength(): int
147
    {
148 420
        return $this->length;
149
    }
150
151
    /**
152
     * {@inheritdoc}
153
     */
154 417
    public function setLength(int $length)
155
    {
156 417
        $this->length = $length;
157 417
    }
158
159
    /**
160
     * {@inheritdoc}
161
     */
162 66
    public function getOriginalLength(): int
163
    {
164 66
        return $this->originalLength;
165
    }
166
167
    /**
168
     * {@inheritdoc}
169
     */
170 714
    public function getInlineNode(): AbstractStringContainer
171
    {
172 714
        return $this->inlineNode;
173
    }
174
175
    /**
176
     * {@inheritdoc}
177
     */
178 993
    public function getPrevious(): ?DelimiterInterface
179
    {
180 993
        return $this->previous;
181
    }
182
183
    /**
184
     * {@inheritdoc}
185
     */
186 993
    public function setPrevious(?DelimiterInterface $previous): DelimiterInterface
187
    {
188 993
        $this->previous = $previous;
189
190 993
        return $this;
191
    }
192
}
193