AccountContact::fromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 14
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 16
ccs 15
cts 15
cp 1
crap 1
rs 9.7998
1
<?php
2
3
namespace Level23\Dynadot\Dto;
4
5
final class AccountContact implements DtoInterface
6
{
7
    public string $organization;
8
    public string $name;
9
    public string $email;
10
    public string $phoneNumber;
11
    public string $phoneCc;
12
    public string $faxNumber;
13
    public string $faxCc;
14
    public string $address1;
15
    public string $address2;
16
    public string $city;
17
    public string $state;
18
    public string $zip;
19
    public string $country;
20
21 1
    public function __construct(
22
        string $organization = '',
23
        string $name = '',
24
        string $email = '',
25
        string $phoneNumber = '',
26
        string $phoneCc = '',
27
        string $faxNumber = '',
28
        string $faxCc = '',
29
        string $address1 = '',
30
        string $address2 = '',
31
        string $city = '',
32
        string $state = '',
33
        string $zip = '',
34
        string $country = ''
35
    ) {
36 1
        $this->organization = $organization;
37 1
        $this->name         = $name;
38 1
        $this->email        = $email;
39 1
        $this->phoneNumber  = $phoneNumber;
40 1
        $this->phoneCc      = $phoneCc;
41 1
        $this->faxNumber    = $faxNumber;
42 1
        $this->faxCc        = $faxCc;
43 1
        $this->address1     = $address1;
44 1
        $this->address2     = $address2;
45 1
        $this->city         = $city;
46 1
        $this->state        = $state;
47 1
        $this->zip          = $zip;
48 1
        $this->country      = $country;
49
    }
50
51 1
    public static function fromArray(array $data): self
52
    {
53 1
        return new self(
54 1
            $data['organization'] ?? '',
55 1
            $data['name'] ?? '',
56 1
            $data['email'] ?? '',
57 1
            $data['phone_number'] ?? '',
58 1
            $data['phone_cc'] ?? '',
59 1
            $data['fax_number'] ?? '',
60 1
            $data['fax_cc'] ?? '',
61 1
            $data['address1'] ?? '',
62 1
            $data['address2'] ?? '',
63 1
            $data['city'] ?? '',
64 1
            $data['state'] ?? '',
65 1
            $data['zip'] ?? '',
66 1
            $data['country'] ?? ''
67 1
        );
68
    }
69
70
    /**
71
     * @return array<string, string>
72
     */
73
    public function jsonSerialize(): array
74
    {
75
        return [
76
            'organization' => $this->organization,
77
            'name'         => $this->name,
78
            'email'        => $this->email,
79
            'phone_number' => $this->phoneNumber,
80
            'phone_cc'     => $this->phoneCc,
81
            'fax_number'   => $this->faxNumber,
82
            'fax_cc'       => $this->faxCc,
83
            'address1'     => $this->address1,
84
            'address2'     => $this->address2,
85
            'city'         => $this->city,
86
            'state'        => $this->state,
87
            'zip'          => $this->zip,
88
            'country'      => $this->country,
89
        ];
90
    }
91
}
92