Completed
Pull Request — master (#49)
by Sam
01:29
created

NSEC   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 73
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getNextDomainName() 0 4 1
A setNextDomainName() 0 4 1
A addTypeBitMap() 0 4 1
A clearTypeMap() 0 4 1
A getTypeBitMaps() 0 4 1
A output() 0 8 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
class NSEC implements RdataInterface
15
{
16
    use RdataTrait;
17
18
    const TYPE = 'NSEC';
19
20
    /**
21
     * The Next Domain field contains the next owner name (in the canonical
22
     * ordering of the zone) that has authoritative data or contains a
23
     * delegation point NS RRset.
24
     * {@link https://tools.ietf.org/html/rfc4034#section-4.1.1}.
25
     *
26
     * @var string
27
     */
28
    private $nextDomainName;
29
30
    /**
31
     * @var array
32
     */
33
    private $typeBitMaps = [];
34
35
    /**
36
     * @return string
37
     */
38 2
    public function getNextDomainName(): string
39
    {
40 2
        return $this->nextDomainName;
41
    }
42
43
    /**
44
     * @param string $nextDomainName
45
     */
46 4
    public function setNextDomainName(string $nextDomainName): void
47
    {
48 4
        $this->nextDomainName = $nextDomainName;
49 4
    }
50
51
    /**
52
     * @param string $type
53
     */
54 6
    public function addTypeBitMap(string $type)
55
    {
56 6
        $this->typeBitMaps[] = $type;
57 6
    }
58
59
    /**
60
     * Clears the types from the RDATA.
61
     */
62 2
    public function clearTypeMap(): void
63
    {
64 2
        $this->typeBitMaps = [];
65 2
    }
66
67
    /**
68
     * @return array
69
     */
70 4
    public function getTypeBitMaps(): array
71
    {
72 4
        return $this->typeBitMaps;
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78 2
    public function output(): string
79
    {
80 2
        return sprintf(
81 2
            '%s %s',
82 2
            $this->nextDomainName,
83 2
            implode(' ', $this->typeBitMaps)
84
        );
85
    }
86
}
87