FencedCode   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 13
eloc 23
dl 0
loc 95
ccs 32
cts 32
cp 1
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A setLiteral() 0 3 1
A setOffset() 0 5 1
A getLiteral() 0 3 1
A setInfo() 0 3 1
A getChar() 0 3 1
A setChar() 0 5 1
A getInfoWords() 0 3 2
A getInfo() 0 3 1
A __construct() 0 5 1
A getLength() 0 3 1
A getOffset() 0 3 1
A setLength() 0 5 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
        $this->length = $length;
42 129
        $this->char   = $char;
43 129
        $this->offset = $offset;
44 129
    }
45
46 3
    public function getInfo(): ?string
47
    {
48 3
        return $this->info;
49
    }
50
51
    /**
52
     * @return string[]
53
     */
54 117
    public function getInfoWords(): array
55
    {
56 117
        return \preg_split('/\s+/', $this->info ?? '') ?: [];
57
    }
58
59 114
    public function setInfo(string $info): void
60
    {
61 114
        $this->info = $info;
62 114
    }
63
64 114
    public function getLiteral(): string
65
    {
66 114
        return $this->literal;
67
    }
68
69 114
    public function setLiteral(string $literal): void
70
    {
71 114
        $this->literal = $literal;
72 114
    }
73
74 108
    public function getChar(): string
75
    {
76 108
        return $this->char;
77
    }
78
79
    /**
80
     * @return $this
81
     */
82 3
    public function setChar(string $char): self
83
    {
84 3
        $this->char = $char;
85
86 3
        return $this;
87
    }
88
89 99
    public function getLength(): int
90
    {
91 99
        return $this->length;
92
    }
93
94
    /**
95
     * @return $this
96
     */
97 3
    public function setLength(int $length): self
98
    {
99 3
        $this->length = $length;
100
101 3
        return $this;
102
    }
103
104 102
    public function getOffset(): int
105
    {
106 102
        return $this->offset;
107
    }
108
109
    /**
110
     * @return $this
111
     */
112 3
    public function setOffset(int $offset): self
113
    {
114 3
        $this->offset = $offset;
115
116 3
        return $this;
117
    }
118
}
119