Total Complexity | 7 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
19 | class CNAME implements RdataInterface |
||
20 | { |
||
21 | use RdataTrait; |
||
22 | |||
23 | const TYPE = 'CNAME'; |
||
24 | const TYPE_CODE = 5; |
||
25 | |||
26 | /** |
||
27 | * @var string|null |
||
28 | */ |
||
29 | protected $target; |
||
30 | |||
31 | /** |
||
32 | * @param string $target |
||
33 | */ |
||
34 | 42 | public function setTarget(string $target): void |
|
37 | 42 | } |
|
38 | |||
39 | /** |
||
40 | * @return string |
||
41 | */ |
||
42 | 15 | public function getTarget(): ?string |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | */ |
||
50 | 10 | public function toText(): string |
|
51 | { |
||
52 | 10 | return $this->target ?? ''; |
|
53 | } |
||
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | 5 | public function toWire(): string |
|
59 | { |
||
60 | 5 | if (null === $this->target) { |
|
61 | 1 | throw new \InvalidArgumentException('Target must be set.'); |
|
62 | } |
||
63 | |||
64 | 5 | return self::encodeName($this->target); |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | 14 | public static function fromText(string $text): RdataInterface |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | 10 | public static function fromWire(string $rdata, int &$offset = 0, ?int $rdLength = null): RdataInterface |
|
87 | } |
||
88 | } |
||
89 |