Total Complexity | 9 |
Total Lines | 80 |
Duplicated Lines | 0 % |
Coverage | 91.3% |
Changes | 0 |
1 | <?php |
||
19 | class A implements RdataInterface |
||
20 | { |
||
21 | use RdataTrait; |
||
22 | |||
23 | const TYPE = 'A'; |
||
24 | const TYPE_CODE = 1; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $address; |
||
30 | |||
31 | /** |
||
32 | * @param string $address |
||
33 | */ |
||
34 | 29 | public function setAddress(string $address): void |
|
35 | { |
||
36 | 29 | if (false === @inet_pton($address)) { |
|
37 | throw new \InvalidArgumentException(sprintf('The address "%s" is not a valid IP address.', $address)); |
||
38 | } |
||
39 | |||
40 | 29 | $this->address = $address; |
|
41 | 29 | } |
|
42 | |||
43 | /** |
||
44 | * @return string |
||
45 | */ |
||
46 | 10 | public function getAddress(): ?string |
|
47 | { |
||
48 | 10 | return $this->address; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | 7 | public function toText(): string |
|
55 | { |
||
56 | 7 | return $this->address ?? ''; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | * |
||
62 | * @throws \InvalidArgumentException |
||
63 | */ |
||
64 | 2 | public function toWire(): string |
|
71 | } |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | 9 | public static function fromText(string $text): RdataInterface |
|
82 | } |
||
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | * |
||
87 | * @throws DecodeException |
||
88 | */ |
||
89 | 6 | public static function fromWire(string $rdata): RdataInterface |
|
101 |