Completed
Push — master ( 0df7a1...55f7a9 )
by Christian
07:49
created

CNAMEData   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A __construct() 0 3 1
A toArray() 0 4 1
A getHostname() 0 3 1
A serialize() 0 3 1
A unserialize() 0 4 1
1
<?php
2
namespace RemotelyLiving\PHPDNS\Entities;
3
4
class CNAMEData extends DataAbstract
5
{
6
    /**
7
     * @var \RemotelyLiving\PHPDNS\Entities\Hostname
8
     */
9
    private $hostname;
10
11
    public function __construct(Hostname $hostname)
12
    {
13
        $this->hostname = $hostname;
14
    }
15
16
    public function __toString(): string
17
    {
18
        return (string) $this->hostname;
19
    }
20
21
    public function getHostname(): Hostname
22
    {
23
        return $this->hostname;
24
    }
25
26
    public function toArray(): array
27
    {
28
        return [
29
            'hostname' => (string)$this->hostname,
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->hostname = new Hostname($unserialized['hostname']);
42
    }
43
}
44