Completed
Push — master ( ddc7b5...479f51 )
by Sam
01:38
created

DS::getAlgorithm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
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\DNSSEC;
13
14
use Badcow\DNS\Rdata\RdataInterface;
15
use Badcow\DNS\Rdata\RdataTrait;
16
17
class DS 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 1
    public function getKeyTag(): int
53
    {
54 1
        return $this->keyTag;
55
    }
56
57
    /**
58
     * @param int $keyTag
59
     */
60 2
    public function setKeyTag(int $keyTag): void
61
    {
62 2
        $this->keyTag = $keyTag;
63 2
    }
64
65
    /**
66
     * @return int
67
     */
68 1
    public function getAlgorithm(): int
69
    {
70 1
        return $this->algorithm;
71
    }
72
73
    /**
74
     * @param int $algorithm
75
     */
76 2
    public function setAlgorithm(int $algorithm): void
77
    {
78 2
        $this->algorithm = $algorithm;
79 2
    }
80
81
    /**
82
     * @return int
83
     */
84 1
    public function getDigestType(): int
85
    {
86 1
        return $this->digestType;
87
    }
88
89
    /**
90
     * @param int $digestType
91
     */
92 2
    public function setDigestType(int $digestType): void
93
    {
94 2
        $this->digestType = $digestType;
95 2
    }
96
97
    /**
98
     * @return string
99
     */
100 1
    public function getDigest(): string
101
    {
102 1
        return $this->digest;
103
    }
104
105
    /**
106
     * @param string $digest
107
     */
108 2
    public function setDigest(string $digest): void
109
    {
110 2
        $this->digest = $digest;
111 2
    }
112
113
    /**
114
     * {@inheritdoc}
115
     */
116 1
    public function output(): string
117
    {
118 1
        return sprintf(
119 1
            '%s %s %s %s',
120 1
            $this->keyTag,
121 1
            $this->algorithm,
122 1
            $this->digestType,
123 1
            $this->digest
124
        );
125
    }
126
}
127