1 | <?php |
||
21 | class SOA implements RdataInterface |
||
22 | { |
||
23 | use RdataTrait; |
||
24 | |||
25 | const TYPE = 'SOA'; |
||
26 | const TYPE_CODE = 6; |
||
27 | |||
28 | /** |
||
29 | * The <domain-name> of the name server that was the |
||
30 | * original or primary source of data for this zone. |
||
31 | * |
||
32 | * @var string|null |
||
33 | */ |
||
34 | private $mname; |
||
35 | |||
36 | /** |
||
37 | * A <domain-name> which specifies the mailbox of the |
||
38 | * person responsible for this zone. |
||
39 | * |
||
40 | * @var string|null |
||
41 | */ |
||
42 | private $rname; |
||
43 | |||
44 | /** |
||
45 | * The unsigned 32 bit version number of the original copy |
||
46 | * of the zone. |
||
47 | * |
||
48 | * @var int|null |
||
49 | */ |
||
50 | private $serial; |
||
51 | |||
52 | /** |
||
53 | * A 32 bit time interval before the zone should be |
||
54 | * refreshed. |
||
55 | * |
||
56 | * @var int|null |
||
57 | */ |
||
58 | private $refresh; |
||
59 | |||
60 | /** |
||
61 | * A 32 bit time interval that should elapse before a |
||
62 | * failed refresh should be retried. |
||
63 | * |
||
64 | * @var int|null |
||
65 | */ |
||
66 | private $retry; |
||
67 | |||
68 | /** |
||
69 | * A 32 bit time value that specifies the upper limit on |
||
70 | * the time interval that can elapse before the zone is no |
||
71 | * longer authoritative. |
||
72 | * |
||
73 | * @var int|null |
||
74 | */ |
||
75 | private $expire; |
||
76 | |||
77 | /** |
||
78 | * The unsigned 32 bit minimum TTL field that should be |
||
79 | * exported with any RR from this zone. |
||
80 | * |
||
81 | * @var int|null |
||
82 | */ |
||
83 | private $minimum; |
||
84 | |||
85 | /** |
||
86 | * @param int $expire |
||
87 | */ |
||
88 | 24 | public function setExpire(int $expire): void |
|
92 | |||
93 | /** |
||
94 | * @return int |
||
95 | */ |
||
96 | 5 | public function getExpire(): ?int |
|
100 | |||
101 | /** |
||
102 | * @param int $minimum |
||
103 | */ |
||
104 | 24 | public function setMinimum(int $minimum): void |
|
108 | |||
109 | /** |
||
110 | * @return int |
||
111 | */ |
||
112 | 5 | public function getMinimum(): ?int |
|
116 | |||
117 | /** |
||
118 | * @param string $mname |
||
119 | */ |
||
120 | 24 | public function setMname(string $mname): void |
|
124 | |||
125 | /** |
||
126 | * @return string |
||
127 | */ |
||
128 | 5 | public function getMname(): ?string |
|
132 | |||
133 | /** |
||
134 | * @param int $refresh |
||
135 | */ |
||
136 | 24 | public function setRefresh(int $refresh): void |
|
140 | |||
141 | /** |
||
142 | * @return int |
||
143 | */ |
||
144 | 5 | public function getRefresh(): ?int |
|
148 | |||
149 | /** |
||
150 | * @param int $retry |
||
151 | */ |
||
152 | 24 | public function setRetry(int $retry): void |
|
156 | |||
157 | /** |
||
158 | * @return int |
||
159 | */ |
||
160 | 5 | public function getRetry(): ?int |
|
164 | |||
165 | /** |
||
166 | * @param string $rname |
||
167 | */ |
||
168 | 24 | public function setRname(string $rname): void |
|
172 | |||
173 | /** |
||
174 | * @return string |
||
175 | */ |
||
176 | 5 | public function getRname(): ?string |
|
180 | |||
181 | /** |
||
182 | * @param int $serial |
||
183 | */ |
||
184 | 24 | public function setSerial(int $serial): void |
|
188 | |||
189 | /** |
||
190 | * @return int |
||
191 | */ |
||
192 | 5 | public function getSerial(): ?int |
|
196 | |||
197 | /** |
||
198 | * {@inheritdoc} |
||
199 | */ |
||
200 | 8 | public function toText(): string |
|
223 | |||
224 | /** |
||
225 | * {@inheritdoc} |
||
226 | */ |
||
227 | 1 | public function toWire(): string |
|
228 | { |
||
229 | 1 | if (!isset($this->mname) || |
|
230 | 1 | !isset($this->rname) || |
|
231 | 1 | !isset($this->serial) || |
|
232 | 1 | !isset($this->refresh) || |
|
233 | 1 | !isset($this->retry) || |
|
234 | 1 | !isset($this->expire) || |
|
235 | 1 | !isset($this->minimum)) { |
|
236 | throw new \InvalidArgumentException('All parameters of SOA must be set.'); |
||
237 | } |
||
238 | |||
239 | return |
||
240 | 1 | self::encodeName($this->mname). |
|
241 | 1 | self::encodeName($this->rname). |
|
242 | pack( |
||
243 | 1 | 'NNNNN', |
|
244 | 1 | $this->serial, |
|
245 | 1 | $this->refresh, |
|
246 | 1 | $this->retry, |
|
247 | 1 | $this->expire, |
|
248 | 1 | $this->minimum |
|
249 | ); |
||
250 | } |
||
251 | |||
252 | /** |
||
253 | * {@inheritdoc} |
||
254 | */ |
||
255 | 9 | public static function fromText(string $text): RdataInterface |
|
269 | |||
270 | /** |
||
271 | * {@inheritdoc} |
||
272 | */ |
||
273 | 1 | public static function fromWire(string $string): RdataInterface |
|
295 | } |
||
296 |