Passed
Pull Request — master (#48)
by Christian
02:15
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 implements \Stringable
9
{
10
    public function __construct(private Hostname $hostname)
11
    {
12
    }
13
14
    public function __toString(): string
15
    {
16
        return (string)$this->hostname;
17
    }
18
19
    public function getHostname(): Hostname
20
    {
21
        return $this->hostname;
22
    }
23
24
    public function toArray(): array
25
    {
26
        return [
27
            'hostname' => (string)$this->hostname,
28
        ];
29
    }
30
31
    public function __unserialize(array $unserialized): void
32
    {
33
        $this->hostname = new Hostname($unserialized['hostname']);
34
    }
35
}
36