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

BulkSearchDomainResult::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Level23\Dynadot\Dto;
4
5
final class BulkSearchDomainResult implements DtoInterface
6
{
7
    public string $domainName;
8
    public string $available;
9
10 5
    private function __construct(
11
        string $domainName,
12
        string $available,
13
    ) {
14 5
        $this->domainName = $domainName;
15 5
        $this->available  = $available;
16
    }
17
18
    /**
19
     * Hydrate from Dynadot's response data.
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['domain_name'] ?? '',
28 5
            $data['available'] ?? '',
29 5
        );
30
    }
31
32
    /**
33
     * @return array<string, mixed>
34
     */
35
    public function jsonSerialize(): array
36
    {
37
        return [
38
            'domain_name' => $this->domainName,
39
            'available'   => $this->available,
40
        ];
41
    }
42
}
43