Completed
Push — refactor-parsing ( adbb6b...fbe6de )
by Colin
08:21 queued 07:01
created

FencedCode::getChar()   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
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Extension\CommonMark\Node\Block;
16
17
use League\CommonMark\Node\Block\AbstractBlock;
18
use League\CommonMark\Node\StringContainerInterface;
19
20
class FencedCode extends AbstractBlock implements StringContainerInterface
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $info;
26
27
    /**
28
     * @var string
29
     */
30
    protected $literal = '';
31
32
    /**
33
     * @var int
34
     */
35
    protected $length;
36
37
    /**
38
     * @var string
39
     */
40
    protected $char;
41
42
    /**
43
     * @var int
44
     */
45
    protected $offset;
46
47
    /**
48
     * @param int    $length
49
     * @param string $char
50
     * @param int    $offset
51
     */
52 126
    public function __construct(int $length, string $char, int $offset)
53
    {
54 126
        $this->length = $length;
55 126
        $this->char = $char;
56 126
        $this->offset = $offset;
57 126
    }
58
59
    /**
60
     * @return string
61
     */
62 3
    public function getInfo(): string
63
    {
64 3
        return $this->info;
65
    }
66
67
    /**
68
     * @return string[]
69
     */
70 114
    public function getInfoWords(): array
71
    {
72 114
        return \preg_split('/\s+/', $this->info) ?: [];
73
    }
74
75 111
    public function setInfo(string $info): void
76
    {
77 111
        $this->info = $info;
78 111
    }
79
80 111
    public function getLiteral(): string
81
    {
82 111
        return $this->literal;
83
    }
84
85 111
    public function setLiteral(string $literal): void
86
    {
87 111
        $this->literal = $literal;
88 111
    }
89
90
    /**
91
     * @return string
92
     */
93 105
    public function getChar(): string
94
    {
95 105
        return $this->char;
96
    }
97
98
    /**
99
     * @param string $char
100
     *
101
     * @return $this
102
     */
103 3
    public function setChar(string $char): self
104
    {
105 3
        $this->char = $char;
106
107 3
        return $this;
108
    }
109
110
    /**
111
     * @return int
112
     */
113 96
    public function getLength(): int
114
    {
115 96
        return $this->length;
116
    }
117
118
    /**
119
     * @param int $length
120
     *
121
     * @return $this
122
     */
123 3
    public function setLength(int $length): self
124
    {
125 3
        $this->length = $length;
126
127 3
        return $this;
128
    }
129
130
    /**
131
     * @return int
132
     */
133 99
    public function getOffset(): int
134
    {
135 99
        return $this->offset;
136
    }
137
138
    /**
139
     * @param int $offset
140
     *
141
     * @return $this
142
     */
143 3
    public function setOffset(int $offset): self
144
    {
145 3
        $this->offset = $offset;
146
147 3
        return $this;
148
    }
149
}
150