Total Complexity | 6 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 72.72% |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
5 | final class BulkSearchResult implements DtoInterface |
||
6 | { |
||
7 | /** @var array<BulkSearchDomainResult> */ |
||
8 | public array $domainResults; |
||
9 | |||
10 | /** |
||
11 | * @param array<BulkSearchDomainResult> $domainResults |
||
12 | */ |
||
13 | 8 | private function __construct(array $domainResults) |
|
14 | { |
||
15 | 8 | $this->domainResults = $domainResults; |
|
16 | } |
||
17 | |||
18 | /** |
||
19 | * Hydrate from Dynadot's response "Data" object. |
||
20 | * |
||
21 | * @param array<string,mixed> $data |
||
22 | * @return self |
||
23 | */ |
||
24 | 8 | public static function fromArray(array $data): self |
|
25 | { |
||
26 | 8 | $domainResults = []; |
|
27 | |||
28 | 8 | if (isset($data['domain_result_list']) && is_array($data['domain_result_list'])) { |
|
29 | 6 | foreach ($data['domain_result_list'] as $domainData) { |
|
30 | 5 | $domainResults[] = BulkSearchDomainResult::fromArray($domainData); |
|
31 | } |
||
32 | } |
||
33 | |||
34 | 8 | return new self($domainResults); |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return array<string, mixed> |
||
39 | */ |
||
40 | public function jsonSerialize(): array |
||
44 | ]; |
||
45 | } |
||
46 | } |
||
47 |