Completed
Pull Request — master (#5)
by Christian
02:05
created

NSData::getTarget()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace RemotelyLiving\PHPDNS\Entities;
3
4
class NSData extends DataAbstract
5
{
6
    /**
7
     * @var \RemotelyLiving\PHPDNS\Entities\Hostname
8
     */
9
    private $target;
10
11
    public function __construct(Hostname $target)
12
    {
13
        $this->target = $target;
14
    }
15
16
    public function __toString(): string
17
    {
18
        return (string)$this->target;
19
    }
20
21
    public function getTarget(): Hostname
22
    {
23
        return $this->target;
24
    }
25
26
    public function toArray(): array
27
    {
28
        return [
29
            'target' => (string)$this->target,
30
        ];
31
    }
32
33
    public function serialize(): string
34
    {
35
        return \serialize($this->toArray());
36
    }
37
38
    public function unserialize($serialized): void
39
    {
40
        $unserialized = \unserialize($serialized);
41
        $this->target = new Hostname($unserialized['target']);
42
    }
43
}
44