1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace RemotelyLiving\PHPDNS\Entities; |
4
|
|
|
|
5
|
|
|
use function serialize; |
6
|
|
|
use function unserialize; |
7
|
|
|
use function vsprintf; |
8
|
|
|
|
9
|
|
|
final class SOAData extends DataAbstract implements \Stringable |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var string |
13
|
|
|
*/ |
14
|
|
|
private const TEMPLATE = '%s %s %s %s %s %s %s'; |
15
|
|
|
|
16
|
|
|
public function __construct( |
17
|
|
|
private Hostname $mname, |
18
|
|
|
private Hostname $rname, |
19
|
|
|
private int $serial, |
20
|
|
|
private int $refresh, |
21
|
|
|
private int $retry, |
22
|
|
|
private int $expire, |
23
|
|
|
private int $minTTL |
24
|
|
|
) { |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function __toString(): string |
28
|
|
|
{ |
29
|
|
|
return vsprintf(self::TEMPLATE, $this->toArray()); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function getMname(): Hostname |
33
|
|
|
{ |
34
|
|
|
return $this->mname; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function getRname(): Hostname |
38
|
|
|
{ |
39
|
|
|
return $this->rname; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function getSerial(): int |
43
|
|
|
{ |
44
|
|
|
return $this->serial; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function getRefresh(): int |
48
|
|
|
{ |
49
|
|
|
return $this->refresh; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function getRetry(): int |
53
|
|
|
{ |
54
|
|
|
return $this->retry; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getExpire(): int |
58
|
|
|
{ |
59
|
|
|
return $this->expire; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getMinTTL(): int |
63
|
|
|
{ |
64
|
|
|
return $this->minTTL; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
public function toArray(): array |
69
|
|
|
{ |
70
|
|
|
return [ |
71
|
|
|
'mname' => (string)$this->mname, |
72
|
|
|
'rname' => (string)$this->rname, |
73
|
|
|
'serial' => $this->serial, |
74
|
|
|
'refresh' => $this->refresh, |
75
|
|
|
'retry' => $this->retry, |
76
|
|
|
'expire' => $this->expire, |
77
|
|
|
'minimumTTL' => $this->minTTL, |
78
|
|
|
]; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function __unserialize(array $unserialized): void |
82
|
|
|
{ |
83
|
|
|
$this->mname = new Hostname($unserialized['mname']); |
84
|
|
|
$this->rname = new Hostname($unserialized['rname']); |
85
|
|
|
$this->serial = $unserialized['serial']; |
86
|
|
|
$this->refresh = $unserialized['refresh']; |
87
|
|
|
$this->retry = $unserialized['retry']; |
88
|
|
|
$this->expire = $unserialized['expire']; |
89
|
|
|
$this->minTTL = $unserialized['minimumTTL']; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|