Completed
Branch phpstan (92b7c6)
by Sam
03:09
created

TXT::setText()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.1481

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 4
cts 6
cp 0.6667
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.1481
1
<?php
2
3
/*
4
 * This file is part of Badcow DNS Library.
5
 *
6
 * (c) Samuel Williams <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Badcow\DNS\Rdata;
13
14
/**
15
 * @see https://tools.ietf.org/html/rfc1035#section-3.3.14
16
 */
17
class TXT implements RdataInterface
18
{
19
    use RdataTrait;
20
21
    const TYPE = 'TXT';
22
23
    /**
24
     * @var string|null
25
     */
26
    private $text;
27
28
    /**
29
     * @param string|null $text
30
     */
31 14
    public function setText(?string $text): void
32
    {
33 14
        if (null === $text) {
34
            $this->text = null;
35
36
            return;
37
        }
38
39 14
        $this->text = addslashes($text);
40 14
    }
41
42
    /**
43
     * @return string|null
44
     */
45 2
    public function getText(): ?string
46
    {
47 2
        return stripslashes((string) $this->text);
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 4
    public function output(): string
54
    {
55 4
        return sprintf('"%s"', $this->text);
56
    }
57
}
58