RP   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 60
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getMailboxDomainName() 0 4 1
A setMailboxDomainName() 0 4 1
A getTxtDomainName() 0 4 1
A setTxtDomainName() 0 4 1
A toText() 0 4 1
A toWire() 0 4 1
A fromText() 0 6 1
A fromWire() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Badcow DNS Library.
7
 *
8
 * (c) Samuel Williams <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Badcow\DNS\Rdata;
15
16
use Badcow\DNS\Message;
17
use Badcow\DNS\Parser\Tokens;
18
19
/**
20
 * {@link https://tools.ietf.org/html/rfc1183}.
21
 */
22
class RP implements RdataInterface
23
{
24 1
    use RdataTrait;
25
26
    const TYPE = 'RP';
27
    const TYPE_CODE = 17;
28
29
    /**
30
     * @var string
31
     */
32
    private $mailboxDomainName;
33
34
    /**
35
     * @var string
36
     */
37
    private $txtDomainName;
38
39 1
    public function getMailboxDomainName(): string
40
    {
41 1
        return $this->mailboxDomainName;
42
    }
43
44 5
    public function setMailboxDomainName(string $mailboxDomainName): void
45
    {
46 5
        $this->mailboxDomainName = $mailboxDomainName;
47 5
    }
48
49 1
    public function getTxtDomainName(): string
50
    {
51 1
        return $this->txtDomainName;
52
    }
53
54 5
    public function setTxtDomainName(string $txtDomainName): void
55
    {
56 5
        $this->txtDomainName = $txtDomainName;
57 5
    }
58
59 3
    public function toText(): string
60
    {
61 3
        return sprintf('%s %s', $this->mailboxDomainName, $this->txtDomainName);
62
    }
63
64 1
    public function toWire(): string
65
    {
66 1
        return Message::encodeName($this->mailboxDomainName).Message::encodeName($this->txtDomainName);
67
    }
68
69 1
    public function fromText(string $text): void
70
    {
71 1
        $rdata = explode(Tokens::SPACE, $text);
72 1
        $this->setMailboxDomainName($rdata[0]);
73 1
        $this->setTxtDomainName($rdata[1]);
74 1
    }
75
76 1
    public function fromWire(string $rdata, int &$offset = 0, ?int $rdLength = null): void
77
    {
78 1
        $this->setMailboxDomainName(Message::decodeName($rdata, $offset));
79 1
        $this->setTxtDomainName(Message::decodeName($rdata, $offset));
80 1
    }
81
}
82