Passed
Pull Request — 2.8 (#1109)
by
unknown
30:48
created

Text   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 31
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A setDelimiter() 0 3 1
A isDelimiter() 0 3 1
A append() 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\Node\Inline;
18
19
final class Text extends AbstractStringContainer
20
{
21 254
    private bool $isDelimiter = false;
22
23 254
    /**
24
     * @param string               $contents The text contents
25
     * @param array<string, mixed> $data     Arbitrary data
26
     */
27
    public function __construct(string $contents = '', array $data = [])
28
    {
29
        if (isset($data['delim'])) {
30
            $this->isDelimiter = (bool) $data['delim'];
31
            unset($data['delim']);
32
        }
33
34
        parent::__construct($contents, $data);
35
    }
36
37
    public function isDelimiter(): bool
38
    {
39
        return $this->isDelimiter;
40
    }
41
42
    public function setDelimiter(bool $isDelimiter): void
43
    {
44
        $this->isDelimiter = $isDelimiter;
45
    }
46
47
    public function append(string $literal): void
48
    {
49
        $this->literal .= $literal;
50
    }
51
}
52