PriceList   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
eloc 22
c 2
b 0
f 2
dl 0
loc 44
ccs 19
cts 19
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A fromArray() 0 11 1
A jsonSerialize() 0 9 1
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 8
    private function __construct()
15
    {
16 8
    }
17
18
    /**
19
     * Hydrate from Dynadot's response data.
20
     *
21
     * @param array<string,mixed> $data
22
     * @return self
23
     */
24 8
    public static function fromArray(array $data): self
25
    {
26 8
        $dto               = new self();
27 8
        $dto->currency     = $data['currency'] ?? '';
28 8
        $dto->unit         = $data['unit'] ?? '';
29 8
        $dto->registration = $data['registration'] ?? '';
30 8
        $dto->renewal      = $data['renewal'] ?? '';
31 8
        $dto->transfer     = $data['transfer'] ?? '';
32 8
        $dto->restore      = $data['restore'] ?? '';
33
34 8
        return $dto;
35
    }
36
37
    /**
38
     * @return array<string, mixed>
39
     */
40 2
    public function jsonSerialize(): array
41
    {
42 2
        return [
43 2
            'currency'     => $this->currency,
44 2
            'unit'         => $this->unit,
45 2
            'transfer'     => $this->transfer,
46 2
            'restore'      => $this->restore,
47 2
            'registration' => $this->registration,
48 2
            'renewal'      => $this->renewal,
49 2
        ];
50
    }
51
}
52