Passed
Push — master ( c5f2a7...8e75e2 )
by Christian
02:33
created

CAAData::getTag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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