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

Text::append()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
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