Passed
Pull Request — master (#24)
by
unknown
09:22
created

SRVData::getPriority()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
namespace RemotelyLiving\PHPDNS\Entities;
3
4
class SRVData extends DataAbstract
5
{
6
    /**
7
     * @var string
8
     */
9
    private $value;
10
    private $weight;
11
    private $target;
12
    private $priority;
13
    private $port;
14
15
    public function __construct(int $priority, int $weight, int $port, Hostname $target, string $value)
16
    {
17
        $this->priority = $priority;
18
        $this->target = $target;
19
        $this->value = $value;
20
        $this->weight = $weight;
21
        $this->port = $port;
22
        
23
    }
24
25
    public function __toString(): string
26
    {
27
        return "{$this->priority} {$this->weight} {$this->port} {$this->target}";
28
    }
29
30
    public function getPriority(): string
31
    {
32
        return $this->priority;
33
    }
34
35
    public function getTarget(): string
36
    {
37
        return $this->target;
38
    }
39
40
    public function getValue(): string
41
    {
42
        return $this->value;
43
    }
44
45
    public function getWeight(): string
46
    {
47
        return $this->weight;
48
    }
49
50
    public function toArray(): array
51
    {
52
        return [
53
            'priority' => $this->priority,
54
            'weight'  => $this->weight,
55
            'port'    => $this->port,
56
            'target' => $this->target,
57
            'value' => $this->value                        
58
        ];
59
    }
60
61
    public function serialize(): string
62
    {
63
        return \serialize($this->toArray());
64
    }
65
66
    /**
67
     * @param string $serialized
68
     */
69
    public function unserialize($serialized): void
70
    {
71
        $unserialized = \unserialize($serialized);
72
        $this->priority = $unserialized['priority'];
73
        $this->weight = $unserialized['weight'];
74
        $this->port = $unserialized['port'];
75
        $this->target = new Hostname($unserialized['target']);
76
        $this->value = $unserialized['value'];
77
        
78
    }
79
}
80