Completed
Pull Request — master (#18)
by Sam
02:22
created

DsRdata   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 110
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 9
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 110
ccs 20
cts 28
cp 0.7143
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getKeyTag() 0 4 1
A setKeyTag() 0 4 1
A getAlgorithm() 0 4 1
A setAlgorithm() 0 4 1
A getDigestType() 0 4 1
A setDigestType() 0 4 1
A getDigest() 0 4 1
A setDigest() 0 4 1
A output() 0 10 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
}