Passed
Push — master ( 79069a...205e6e )
by SignpostMarv
11:50
created

GeoCoordinates::SetLongitude()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
* @author SignpostMarv
4
*/
5
declare(strict_types=1);
6
7
namespace SignpostMarv\DaftObject\SchemaOrg;
8
9
use SignpostMarv\DaftObject\SchemaOrg\Intangible\StructuredValue\ContactPoint\PostalAddress;
10
use SignpostMarv\DaftObject\SchemaOrg\Place\AdministrativeArea\Country;
11
12
/**
13
* @property array<int, string|PostalAddress> $address
14
* @property array<int, string|Country> $addressCountry
15
* @property array<int, string|float|int> $elevation
16
* @property array<int, string|float|int> $latitude
17
* @property array<int, string|float|int> $longitude
18
* @property array<int, string> $postalCode
19
*/
20
class GeoCoordinates extends Thing
21
{
22
    use DaftObjectTraits\HasAddress;
23
    use DaftObjectTraits\HasAddressCountry;
24
    use DaftObjectTraits\HasElevation;
25
    use DaftObjectTraits\HasPostalCode;
26
27
    const SCHEMA_ORG_TYPE = 'GeoCoordinates';
28
29
    const PROPERTIES = [
30
        'address',
31
        'addressCountry',
32
        'elevation',
33
        'latitude',
34
        'longitude',
35
        'postalCode',
36
    ];
37
38
    const PROPERTIES_WITH_MULTI_TYPED_ARRAYS = [
39
        'address' => [
40
            'string',
41
            PostalAddress::class,
42
        ],
43
        'addressCountry' => [
44
            'string',
45
            Country::class,
46
        ],
47
        'elevation' => [
48
            'string',
49
            'double',
50
            'integer',
51
        ],
52
        'latitude' => [
53
            'string',
54
            'double',
55
            'integer',
56
        ],
57
        'longitude' => [
58
            'string',
59
            'double',
60
            'integer',
61
        ],
62
        'postalCode' => [
63
            'string',
64
        ],
65
    ];
66
67
    /**
68
    * @return array<int, string|float|int>
69
    */
70 6
    public function GetLatitude() : array
71
    {
72
        /**
73
        * @var array<int, string|float|int>
74
        */
75 6
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
76 6
            'latitude',
77 6
            $this->RetrievePropertyValueFromData('latitude'),
78 6
            static::class
79
        );
80
81 6
        return $out;
82
    }
83
84
    /**
85
    * @param array<int, string|float|int> $value
86
    */
87 1
    public function SetLatitude(array $value) : void
88
    {
89 1
        $this->NudgePropertyWithUniqueTrimmedStringsNumericsMightNotBeStringsOrNumerics(
90 1
            'latitude',
91 1
            __METHOD__,
92 1
            $value
93
        );
94 1
    }
95
96
    /**
97
    * @return array<int, string|float|int>
98
    */
99 6
    public function GetLongitude() : array
100
    {
101
        /**
102
        * @var array<int, string|float|int>
103
        */
104 6
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
105 6
            'longitude',
106 6
            $this->RetrievePropertyValueFromData('longitude'),
107 6
            static::class
108
        );
109
110 6
        return $out;
111
    }
112
113
    /**
114
    * @param array<int, string|float|int> $value
115
    */
116 1
    public function SetLongitude(array $value) : void
117
    {
118 1
        $this->NudgePropertyWithUniqueTrimmedStringsNumericsMightNotBeStringsOrNumerics(
119 1
            'longitude',
120 1
            __METHOD__,
121 1
            $value
122
        );
123 1
    }
124
}
125