RRSet   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 192
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 33
c 2
b 0
f 0
dl 0
loc 192
rs 10
wmc 14

14 Methods

Rating   Name   Duplication   Size   Complexity  
A addComment() 0 5 1
A addRecord() 0 5 1
A setTtl() 0 5 1
A setChangetype() 0 5 1
A getRecords() 0 3 1
A getType() 0 3 1
A setComments() 0 6 1
A setType() 0 5 1
A getName() 0 3 1
A getComments() 0 3 1
A getChangetype() 0 3 1
A setName() 0 5 1
A setRecords() 0 5 1
A getTtl() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the CwdPowerDNS Client
5
 *
6
 * (c) 2018 cwd.at GmbH <[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
declare(strict_types=1);
13
14
namespace Cwd\PowerDNSClient\Model\Zone;
15
16
use Symfony\Component\Serializer\Annotation\Groups;
17
use Symfony\Component\Validator\Constraints as Assert;
18
use Cwd\PowerDNSClient\Validator\Constraints as DNSAssert;
19
20
class RRSet
21
{
22
    public const TYPE_REPLACE = 'REPLACE';
23
    public const TYPE_DELETE = 'DELETE';
24
    public const TYPE_CREATE = 'REPLACE'; // Yes this is by design!
25
26
    /**
27
     * @var string
28
     * @Assert\NotBlank(groups={"CREATE", "UPDATE"})
29
     * @DNSAssert\HasDotPostfix(groups={"CREATE", "UPDATE"})
30
     *
31
     * @Groups({"REPLACE", "CREATE", "DELETE"})
32
     */
33
    protected $name;
34
35
    /**
36
     * @var string
37
     * @Assert\NotBlank(groups={"CREATE", "UPDATE"})
38
     * @Assert\Choice(
39
     *    groups={"CREATE", "UPDATE"},
40
     *    choices={
41
     *     "A", "AAAA", "AFSDB", "ALIAS", "CAA", "CERT", "CDNSKEY", "CDS", "CNAME", "DNSKEY", "DNAME", "DS", "HINFO",
42
     *     "KEY", "LOC", "MX", "NAPTR", "NS", "NSEC, NSEC3, NSEC3PARAM", "OPENPGPKEY", "PTR", "RP", "RRSIG", "SOA",
43
     *     "SPF", "SSHFP", "SRV", "TKEY, TSIG", "TLSA", "SMIMEA", "TXT", "URI"
44
     *    }
45
     * )
46
     * @Groups({"REPLACE", "CREATE", "DELETE"})
47
     */
48
    protected $type;
49
    /**
50
     * @var int
51
     * @Groups({"REPLACE", "CREATE"})
52
     */
53
    protected $ttl;
54
55
    /**
56
     * @var string
57
     * @Assert\Choice(
58
     *    choices={"REPLACE", "DELETE", "CREATE"},
59
     *    groups={"CREATE", "UPDATE"}
60
     * )
61
     * @Groups({"REPLACE", "DELETE"})
62
     */
63
    protected $changetype;
64
65
    /**
66
     * @var Record[]
67
     * @Assert\Valid(groups={"CREATE", "UPDATE"})
68
     * @Groups({"REPLACE", "CREATE"})
69
     */
70
    protected $records = [];
71
72
    /**
73
     * @var Comment[]
74
     * @Assert\Valid(groups={"CREATE", "UPDATE"})
75
     * @Groups({"REPLACE", "CREATE"})
76
     */
77
    protected $comments = [];
78
79
    /**
80
     * @return string
81
     */
82
    public function getName(): string
83
    {
84
        return $this->name;
85
    }
86
87
    /**
88
     * @param string $name
89
     *
90
     * @return RRSet
91
     */
92
    public function setName(string $name): RRSet
93
    {
94
        $this->name = $name;
95
96
        return $this;
97
    }
98
99
    /**
100
     * @return string
101
     */
102
    public function getType(): string
103
    {
104
        return $this->type;
105
    }
106
107
    /**
108
     * @param string $type
109
     *
110
     * @return RRSet
111
     */
112
    public function setType(string $type): RRSet
113
    {
114
        $this->type = $type;
115
116
        return $this;
117
    }
118
119
    /**
120
     * @return int
121
     */
122
    public function getTtl(): int
123
    {
124
        return $this->ttl;
125
    }
126
127
    /**
128
     * @param int $ttl
129
     *
130
     * @return RRSet
131
     */
132
    public function setTtl(int $ttl): RRSet
133
    {
134
        $this->ttl = $ttl;
135
136
        return $this;
137
    }
138
139
    /**
140
     * @return string
141
     */
142
    public function getChangetype(): ?string
143
    {
144
        return $this->changetype;
145
    }
146
147
    /**
148
     * @param string $changetype
149
     *
150
     * @return RRSet
151
     */
152
    public function setChangetype(?string $changetype): RRSet
153
    {
154
        $this->changetype = $changetype;
155
156
        return $this;
157
    }
158
159
    /**
160
     * @return Record[]
161
     */
162
    public function getRecords(): array
163
    {
164
        return $this->records;
165
    }
166
167
    /**
168
     * @param Record[] $records
169
     *
170
     * @return RRSet
171
     */
172
    public function setRecords(array $records): RRSet
173
    {
174
        $this->records = $records;
175
176
        return $this;
177
    }
178
179
    public function addRecord(Record $record): RRSet
180
    {
181
        $this->records[] = $record;
182
183
        return $this;
184
    }
185
186
    /**
187
     * @return Comment[]
188
     */
189
    public function getComments(): array
190
    {
191
        return $this->comments;
192
    }
193
194
    /**
195
     * @param Comment[] $comments
196
     *
197
     * @return RRSet
198
     */
199
    public function setComments(array $comments): RRSet
200
    {
201
        \Webmozart\Assert\Assert::allIsInstanceOf($comments, Comment::class);
202
        $this->comments = $comments;
203
204
        return $this;
205
    }
206
207
    public function addComment(Comment $comment): RRSet
208
    {
209
        $this->comments[] = $comment;
210
211
        return $this;
212
    }
213
}
214