Total Complexity | 10 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
13 | final class CAAData extends DataAbstract implements \Stringable |
||
14 | { |
||
15 | private ?string $value; |
||
16 | |||
17 | public function __construct(private int $flags, private string $tag, string $value = null) |
||
18 | { |
||
19 | $this->value = ($value) |
||
20 | ? $this->normalizeValue($value) |
||
21 | : null; |
||
22 | } |
||
23 | |||
24 | public function __toString(): string |
||
25 | { |
||
26 | return "{$this->flags} {$this->tag} \"{$this->value}\""; |
||
27 | } |
||
28 | |||
29 | public function __unserialize(array $unserialized): void |
||
30 | { |
||
31 | $this->flags = $unserialized['flags']; |
||
32 | $this->tag = $unserialized['tag']; |
||
33 | $this->value = $unserialized['value']; |
||
34 | } |
||
35 | |||
36 | public function getFlags(): int |
||
37 | { |
||
38 | return $this->flags; |
||
39 | } |
||
40 | |||
41 | public function getTag(): string |
||
42 | { |
||
43 | return $this->tag; |
||
44 | } |
||
45 | |||
46 | public function getValue(): ?string |
||
49 | } |
||
50 | |||
51 | public function toArray(): array |
||
57 | ]; |
||
58 | } |
||
59 | |||
60 | private function normalizeValue(string $value): string |
||
61 | { |
||
62 | $normalized = trim(str_ireplace('"', '', $value)); |
||
71 |