Test Failed
Pull Request — master (#10)
by
unknown
14:44
created

PriceList::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 0
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 1
ccs 0
cts 1
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Level23\Dynadot\Dto;
4
5
final class PriceList implements DtoInterface
6
{
7
    public string $currency;
8
    public string $unit;
9
    public string $transfer;
10
    public string $restore;
11
    public string $registration;
12
    public string $renewal;
13
14
    private function __construct() {}
15
16
    /**
17
     * Hydrate from Dynadot's response data.
18
     *
19
     * @param array<string,mixed> $data
20
     * @return self
21
     */
22
    public static function fromArray(array $data): self
23
    {
24
        $dto = new self();
25
        $dto->currency = $data['currency'] ?? '';
26
        $dto->unit = $data['unit'] ?? '';
27
        $dto->registration = $data['registration'] ?? '';
28
        $dto->renewal = $data['renewal'] ?? '';
29
        $dto->transfer = $data['transfer'] ?? '';
30
        $dto->restore = $data['restore'] ?? '';
31
        return $dto;
32
    }
33
34
    /**
35
     * @return array<string, mixed>
36
     */
37
    public function jsonSerialize(): array
38
    {
39
        return [
40
            'currency' => $this->currency,
41
            'unit' => $this->unit,
42
            'transfer' => $this->transfer,
43
            'restore' => $this->restore,
44
            'registration' => $this->registration,
45
            'renewal' => $this->renewal,
46
        ];
47
    }
48
}