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

DS::output()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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 DS implements RdataInterface
15
{
16
    use RdataTrait;
17
18
    const TYPE = 'DS';
19
20
    const DIGEST_SHA1 = 1;
21
22
    /**
23
     * @var int
24
     */
25
    private $keyTag;
26
27
    /**
28
     * The Algorithm field lists the algorithm number of the DNSKEY RR
29
     * referred to by the DS record.
30
     * {@link https://tools.ietf.org/html/rfc4034#section-5.1.2}.
31
     *
32
     * @var int
33
     */
34
    private $algorithm;
35
36
    /**
37
     * @var int
38
     */
39
    private $digestType = self::DIGEST_SHA1;
40
41
    /**
42
     * @var string
43
     */
44
    private $digest;
45
46
    /**
47
     * @return int
48
     */
49 2
    public function getKeyTag(): int
50
    {
51 2
        return $this->keyTag;
52
    }
53
54
    /**
55
     * @param int $keyTag
56
     */
57 4
    public function setKeyTag(int $keyTag): void
58
    {
59 4
        $this->keyTag = $keyTag;
60 4
    }
61
62
    /**
63
     * @return int
64
     */
65 2
    public function getAlgorithm(): int
66
    {
67 2
        return $this->algorithm;
68
    }
69
70
    /**
71
     * @param int $algorithm
72
     */
73 4
    public function setAlgorithm(int $algorithm): void
74
    {
75 4
        $this->algorithm = $algorithm;
76 4
    }
77
78
    /**
79
     * @return int
80
     */
81 2
    public function getDigestType(): int
82
    {
83 2
        return $this->digestType;
84
    }
85
86
    /**
87
     * @param int $digestType
88
     */
89 4
    public function setDigestType(int $digestType): void
90
    {
91 4
        $this->digestType = $digestType;
92 4
    }
93
94
    /**
95
     * @return string
96
     */
97 2
    public function getDigest(): string
98
    {
99 2
        return $this->digest;
100
    }
101
102
    /**
103
     * @param string $digest
104
     */
105 4
    public function setDigest(string $digest): void
106
    {
107 4
        $this->digest = $digest;
108 4
    }
109
110
    /**
111
     * {@inheritdoc}
112
     */
113 2
    public function output(): string
114
    {
115 2
        return sprintf(
116 2
            '%s %s %s %s',
117 2
            $this->keyTag,
118 2
            $this->algorithm,
119 2
            $this->digestType,
120 2
            $this->digest
121
        );
122
    }
123
}
124