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

TXT   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 41
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setText() 0 10 2
A getText() 0 4 1
A output() 0 4 1
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