Passed
Push — master ( c81968...b18996 )
by Maximilian
01:27 queued 12s
created

DeviceAddressInformation   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 1
eloc 19
c 1
b 1
f 0
dl 0
loc 61
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromApiResponse() 0 14 1
1
<?php
2
3
namespace MaxBeckers\AmazonAlexa\Request\Device;
4
5
use MaxBeckers\AmazonAlexa\Helper\PropertyHelper;
6
7
/**
8
 * @author Maximilian Beckers <[email protected]>
9
 */
10
class DeviceAddressInformation
11
{
12
    /**
13
     * @var string|null
14
     */
15
    public $stateOrRegion;
16
17
    /**
18
     * @var string|null
19
     */
20
    public $city;
21
22
    /**
23
     * @var string|null
24
     */
25
    public $countryCode;
26
27
    /**
28
     * @var string|null
29
     */
30
    public $postalCode;
31
32
    /**
33
     * @var string|null
34
     */
35
    public $addressLine1;
36
37
    /**
38
     * @var string|null
39
     */
40
    public $addressLine2;
41
42
    /**
43
     * @var string|null
44
     */
45
    public $addressLine3;
46
47
    /**
48
     * @var string|null
49
     */
50
    public $districtOrCounty;
51
52
    /**
53
     * @param array $amazonApiResponse
54
     *
55
     * @return DeviceAddressInformation
56
     */
57 2
    public static function fromApiResponse(array $amazonApiResponse): self
58
    {
59 2
        $deviceAddressInformation = new self();
60
61 2
        $deviceAddressInformation->stateOrRegion    = PropertyHelper::checkNullValueString($amazonApiResponse, 'stateOrRegion');
62 2
        $deviceAddressInformation->city             = PropertyHelper::checkNullValueString($amazonApiResponse, 'city');
63 2
        $deviceAddressInformation->countryCode      = PropertyHelper::checkNullValueString($amazonApiResponse, 'countryCode');
64 2
        $deviceAddressInformation->postalCode       = PropertyHelper::checkNullValueString($amazonApiResponse, 'postalCode');
65 2
        $deviceAddressInformation->addressLine1     = PropertyHelper::checkNullValueString($amazonApiResponse, 'addressLine1');
66 2
        $deviceAddressInformation->addressLine2     = PropertyHelper::checkNullValueString($amazonApiResponse, 'addressLine2');
67 2
        $deviceAddressInformation->addressLine3     = PropertyHelper::checkNullValueString($amazonApiResponse, 'addressLine3');
68 2
        $deviceAddressInformation->districtOrCounty = PropertyHelper::checkNullValueString($amazonApiResponse, 'districtOrCounty');
69
70 2
        return $deviceAddressInformation;
71
    }
72
}
73