Passed
Pull Request — master (#11)
by
unknown
02:34
created

NameserverUpdateResult::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
rs 10
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 6
    private function __construct(
11
        int $code,
12
        string $message,
13
    ) {
14 6
        $this->code    = $code;
15 6
        $this->message = $message;
16
    }
17
18
    /**
19
     * Hydrate from Dynadot's response.
20
     *
21
     * @param array<string,mixed> $data
22
     * @return self
23
     */
24 6
    public static function fromArray(array $data): self
25
    {
26 6
        return new self(
27 6
            $data['code'] ?? 0,
28 6
            $data['message'] ?? '',
29 6
        );
30
    }
31
32
    /**
33
     * @return array<string, mixed>
34
     */
35 1
    public function jsonSerialize(): array
36
    {
37 1
        return [
38 1
            'code'    => $this->code,
39 1
            'message' => $this->message,
40 1
        ];
41
    }
42
}
43