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

DomainInfo::fromArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 21
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 23
ccs 0
cts 22
cp 0
crap 2
rs 9.584
1
<?php
2
3
namespace Level23\Dynadot\Dto;
4
5
final class DomainInfo implements DtoInterface
6
{
7
    public string $domainName;
8
    public int $expiration;
9
    public int $registration;
10
    /** @var array<string, string> */
11
    public array $glueInfo;
12
    public int $registrantContactId;
13
    public int $adminContactId;
14
    public int $techContactId;
15
    public int $billingContactId;
16
    public bool $locked;
17
    public bool $disabled;
18
    public bool $udrpLocked;
19
    public bool $registrantUnverified;
20
    public bool $hold;
21
    public string $privacy;
22
    public bool $isForSale;
23
    public string $renewOption;
24
    public ?string $note;
25
    public int $folderId;
26
    public string $folderName;
27
    public string $status;
28
29
    /**
30
     * @param array<string, string> $glueInfo
31
     */
32
    private function __construct(
33
        string $domainName,
34
        int $expiration,
35
        int $registration,
36
        array $glueInfo,
37
        int $registrantContactId,
38
        int $adminContactId,
39
        int $techContactId,
40
        int $billingContactId,
41
        bool $locked,
42
        bool $disabled,
43
        bool $udrpLocked,
44
        bool $registrantUnverified,
45
        bool $hold,
46
        string $privacy,
47
        bool $isForSale,
48
        string $renewOption,
49
        ?string $note,
50
        int $folderId,
51
        string $folderName,
52
        string $status,
53
    ) {
54
        $this->domainName = $domainName;
55
        $this->expiration = $expiration;
56
        $this->registration = $registration;
57
        $this->glueInfo = $glueInfo;
58
        $this->registrantContactId = $registrantContactId;
59
        $this->adminContactId = $adminContactId;
60
        $this->techContactId = $techContactId;
61
        $this->billingContactId = $billingContactId;
62
        $this->locked = $locked;
63
        $this->disabled = $disabled;
64
        $this->udrpLocked = $udrpLocked;
65
        $this->registrantUnverified = $registrantUnverified;
66
        $this->hold = $hold;
67
        $this->privacy = $privacy;
68
        $this->isForSale = $isForSale;
69
        $this->renewOption = $renewOption;
70
        $this->note = $note;
71
        $this->folderId = $folderId;
72
        $this->folderName = $folderName;
73
        $this->status = $status;
74
    }
75
76
    /**
77
     * Hydrate from domain data.
78
     *
79
     * @param array<string,mixed> $data
80
     * @return self
81
     */
82
    public static function fromArray(array $data): self
83
    {
84
        return new self(
85
            $data['domainName'],
86
            $data['expiration'],
87
            $data['registration'],
88
            $data['glueInfo'],
89
            $data['registrant_contactId'],
90
            $data['admin_contactId'],
91
            $data['tech_contactId'],
92
            $data['billing_contactId'],
93
            $data['locked'],
94
            $data['disabled'],
95
            $data['udrpLocked'],
96
            $data['registrantUnverified'],
97
            $data['hold'],
98
            $data['privacy'],
99
            $data['is_for_sale'],
100
            $data['renew_option'],
101
            $data['note'],
102
            $data['folder_id'],
103
            $data['folder_name'],
104
            $data['status'],
105
        );
106
    }
107
108
    /**
109
     * @return array<string, mixed>
110
     */
111
    public function jsonSerialize(): array
112
    {
113
        return [
114
            'domainName' => $this->domainName,
115
            'expiration' => $this->expiration,
116
            'registration' => $this->registration,
117
            'glueInfo' => $this->glueInfo,
118
            'registrant_contact_id' => $this->registrantContactId,
119
            'admin_contact_id' => $this->adminContactId,
120
            'tech_contact_id' => $this->techContactId,
121
            'billing_contact_id' => $this->billingContactId,
122
            'locked' => $this->locked,
123
            'disabled' => $this->disabled,
124
            'udrp_locked' => $this->udrpLocked,
125
            'registrant_unverified' => $this->registrantUnverified,
126
            'hold' => $this->hold,
127
            'privacy' => $this->privacy,
128
            'is_for_sale' => $this->isForSale,
129
            'renew_option' => $this->renewOption,
130
            'note' => $this->note,
131
            'folder_id' => $this->folderId,
132
            'folder_name' => $this->folderName,
133
            'status' => $this->status,
134
        ];
135
    }
136
}