Test Failed
Push — master ( b0fb2b...153449 )
by Christian
41s queued 11s
created

PTRData::unserialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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