FencedCode::getLiteral()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
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
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\Extension\CommonMark\Node\Block;
18
19
use League\CommonMark\Node\Block\AbstractBlock;
20
use League\CommonMark\Node\StringContainerInterface;
21
22
class FencedCode extends AbstractBlock implements StringContainerInterface
23
{
24
    /** @var string|null */
25
    protected $info;
26
27
    /** @var string */
28
    protected $literal = '';
29
30
    /** @var int */
31
    protected $length;
32
33
    /** @var string */
34
    protected $char;
35
36
    /** @var int */
37
    protected $offset;
38
39 129
    public function __construct(int $length, string $char, int $offset)
40
    {
41 129
        parent::__construct();
42
43 129
        $this->length = $length;
44 129
        $this->char   = $char;
45 129
        $this->offset = $offset;
46 129
    }
47
48 3
    public function getInfo(): ?string
49
    {
50 3
        return $this->info;
51
    }
52
53
    /**
54
     * @return string[]
55
     */
56 117
    public function getInfoWords(): array
57
    {
58 117
        return \preg_split('/\s+/', $this->info ?? '') ?: [];
59
    }
60
61 114
    public function setInfo(string $info): void
62
    {
63 114
        $this->info = $info;
64 114
    }
65
66 114
    public function getLiteral(): string
67
    {
68 114
        return $this->literal;
69
    }
70
71 114
    public function setLiteral(string $literal): void
72
    {
73 114
        $this->literal = $literal;
74 114
    }
75
76 108
    public function getChar(): string
77
    {
78 108
        return $this->char;
79
    }
80
81 3
    public function setChar(string $char): void
82
    {
83 3
        $this->char = $char;
84 3
    }
85
86 99
    public function getLength(): int
87
    {
88 99
        return $this->length;
89
    }
90
91 3
    public function setLength(int $length): void
92
    {
93 3
        $this->length = $length;
94 3
    }
95
96 102
    public function getOffset(): int
97
    {
98 102
        return $this->offset;
99
    }
100
101 3
    public function setOffset(int $offset): void
102
    {
103 3
        $this->offset = $offset;
104 3
    }
105
}
106