MXData::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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