Completed
Push — master ( 14d35d...e34866 )
by Sam
9s
created

DsRdata::setDigest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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