Delimiter   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 152
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 15
eloc 33
dl 0
loc 152
ccs 41
cts 41
cp 1
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A getNext() 0 3 1
A setLength() 0 3 1
A setActive() 0 3 1
A getPrevious() 0 3 1
A canClose() 0 3 1
A getLength() 0 3 1
A getIndex() 0 3 1
A getChar() 0 3 1
A setNext() 0 3 1
A isActive() 0 3 1
A getOriginalLength() 0 3 1
A setPrevious() 0 3 1
A canOpen() 0 3 1
A getInlineNode() 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
 * 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 1083
    public function __construct(string $char, int $numDelims, AbstractStringContainer $node, bool $canOpen, bool $canClose, ?int $index = null)
94
    {
95 1083
        $this->char           = $char;
96 1083
        $this->length         = $numDelims;
97 1083
        $this->originalLength = $numDelims;
98 1083
        $this->inlineNode     = $node;
99 1083
        $this->canOpen        = $canOpen;
100 1083
        $this->canClose       = $canClose;
101 1083
        $this->active         = true;
102 1083
        $this->index          = $index;
103 1083
    }
104
105 987
    public function canClose(): bool
106
    {
107 987
        return $this->canClose;
108
    }
109
110 585
    public function canOpen(): bool
111
    {
112 585
        return $this->canOpen;
113
    }
114
115 489
    public function isActive(): bool
116
    {
117 489
        return $this->active;
118
    }
119
120 27
    public function setActive(bool $active): void
121
    {
122 27
        $this->active = $active;
123 27
    }
124
125 1071
    public function getChar(): string
126
    {
127 1071
        return $this->char;
128
    }
129
130 306
    public function getIndex(): ?int
131
    {
132 306
        return $this->index;
133
    }
134
135 1071
    public function getNext(): ?DelimiterInterface
136
    {
137 1071
        return $this->next;
138
    }
139
140 591
    public function setNext(?DelimiterInterface $next): void
141
    {
142 591
        $this->next = $next;
143 591
    }
144
145 489
    public function getLength(): int
146
    {
147 489
        return $this->length;
148
    }
149
150 486
    public function setLength(int $length): void
151
    {
152 486
        $this->length = $length;
153 486
    }
154
155 72
    public function getOriginalLength(): int
156
    {
157 72
        return $this->originalLength;
158
    }
159
160 813
    public function getInlineNode(): AbstractStringContainer
161
    {
162 813
        return $this->inlineNode;
163
    }
164
165 1071
    public function getPrevious(): ?DelimiterInterface
166
    {
167 1071
        return $this->previous;
168
    }
169
170 1071
    public function setPrevious(?DelimiterInterface $previous): void
171
    {
172 1071
        $this->previous = $previous;
173 1071
    }
174
}
175