Passed
Pull Request — master (#10)
by
unknown
02:30
created

NameserverUpdateResult   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
eloc 11
c 2
b 0
f 2
dl 0
loc 35
ccs 8
cts 12
cp 0.6667
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 5 1
A fromArray() 0 5 1
A __construct() 0 6 1
1
<?php
2
3
namespace Level23\Dynadot\Dto;
4
5
final class NameserverUpdateResult implements DtoInterface
6
{
7
    public int $code;
8
    public string $message;
9
10 5
    private function __construct(
11
        int $code,
12
        string $message,
13
    ) {
14 5
        $this->code    = $code;
15 5
        $this->message = $message;
16
    }
17
18
    /**
19
     * Hydrate from Dynadot's response.
20
     *
21
     * @param array<string,mixed> $data
22
     * @return self
23
     */
24 5
    public static function fromArray(array $data): self
25
    {
26 5
        return new self(
27 5
            $data['code'] ?? 0,
28 5
            $data['message'] ?? '',
29 5
        );
30
    }
31
32
    /**
33
     * @return array<string, mixed>
34
     */
35
    public function jsonSerialize(): array
36
    {
37
        return [
38
            'code'    => $this->code,
39
            'message' => $this->message,
40
        ];
41
    }
42
}
43