|
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> $box |
|
16
|
|
|
* @property array<int, string> $circle |
|
17
|
|
|
* @property array<int, string|float|int> $elevation |
|
18
|
|
|
* @property array<int, string> $line |
|
19
|
|
|
* @property array<int, string> $polygon |
|
20
|
|
|
* @property array<int, string> $postalCode |
|
21
|
|
|
*/ |
|
22
|
|
|
class GeoShape extends Thing |
|
23
|
|
|
{ |
|
24
|
|
|
use DaftObjectTraits\HasAddress; |
|
25
|
|
|
use DaftObjectTraits\HasAddressCountry; |
|
26
|
|
|
use DaftObjectTraits\HasElevation; |
|
27
|
|
|
use DaftObjectTraits\HasPostalCode; |
|
28
|
|
|
|
|
29
|
|
|
const SCHEMA_ORG_TYPE = 'GeoShape'; |
|
30
|
|
|
|
|
31
|
|
|
const PROPERTIES = [ |
|
32
|
|
|
'address', |
|
33
|
|
|
'addressCountry', |
|
34
|
|
|
'box', |
|
35
|
|
|
'circle', |
|
36
|
|
|
'elevation', |
|
37
|
|
|
'line', |
|
38
|
|
|
'polygon', |
|
39
|
|
|
'postalCode', |
|
40
|
|
|
]; |
|
41
|
|
|
|
|
42
|
|
|
const PROPERTIES_WITH_MULTI_TYPED_ARRAYS = [ |
|
43
|
|
|
'address' => [ |
|
44
|
|
|
'string', |
|
45
|
|
|
PostalAddress::class, |
|
46
|
|
|
], |
|
47
|
|
|
'addressCountry' => [ |
|
48
|
|
|
'string', |
|
49
|
|
|
Country::class, |
|
50
|
|
|
], |
|
51
|
|
|
'box' => [ |
|
52
|
|
|
'string', |
|
53
|
|
|
], |
|
54
|
|
|
'circle' => [ |
|
55
|
|
|
'string', |
|
56
|
|
|
], |
|
57
|
|
|
'elevation' => [ |
|
58
|
|
|
'string', |
|
59
|
|
|
'double', |
|
60
|
|
|
'integer', |
|
61
|
|
|
], |
|
62
|
|
|
'line' => [ |
|
63
|
|
|
'string', |
|
64
|
|
|
], |
|
65
|
|
|
'polygon' => [ |
|
66
|
|
|
'string', |
|
67
|
|
|
], |
|
68
|
|
|
'postalCode' => [ |
|
69
|
|
|
'string', |
|
70
|
|
|
], |
|
71
|
|
|
]; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return array<int, string> |
|
75
|
|
|
*/ |
|
76
|
6 |
|
public function GetBox() : array |
|
77
|
|
|
{ |
|
78
|
|
|
/** |
|
79
|
|
|
* @var array<int, string> |
|
80
|
|
|
*/ |
|
81
|
6 |
|
$out = TypeUtilities::ExpectRetrievedValueIsArray( |
|
82
|
6 |
|
'box', |
|
83
|
6 |
|
$this->RetrievePropertyValueFromData('box'), |
|
84
|
6 |
|
static::class |
|
85
|
|
|
); |
|
86
|
|
|
|
|
87
|
6 |
|
return $out; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @param array<int, string> $value |
|
92
|
|
|
*/ |
|
93
|
1 |
|
public function SetBox(array $value) : void |
|
94
|
|
|
{ |
|
95
|
1 |
|
$this->NudgePropertyWithUniqueTrimmedStringsMightNotBeString( |
|
96
|
1 |
|
'box', |
|
97
|
1 |
|
__METHOD__, |
|
98
|
1 |
|
$value |
|
99
|
|
|
); |
|
100
|
1 |
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @return array<int, string> |
|
104
|
|
|
*/ |
|
105
|
6 |
|
public function GetCircle() : array |
|
106
|
|
|
{ |
|
107
|
|
|
/** |
|
108
|
|
|
* @var array<int, string> |
|
109
|
|
|
*/ |
|
110
|
6 |
|
$out = TypeUtilities::ExpectRetrievedValueIsArray( |
|
111
|
6 |
|
'circle', |
|
112
|
6 |
|
$this->RetrievePropertyValueFromData('circle'), |
|
113
|
6 |
|
static::class |
|
114
|
|
|
); |
|
115
|
|
|
|
|
116
|
6 |
|
return $out; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param array<int, string> $value |
|
121
|
|
|
*/ |
|
122
|
1 |
|
public function SetCircle(array $value) : void |
|
123
|
|
|
{ |
|
124
|
1 |
|
$this->NudgePropertyWithUniqueTrimmedStringsMightNotBeString( |
|
125
|
1 |
|
'circle', |
|
126
|
1 |
|
__METHOD__, |
|
127
|
1 |
|
$value |
|
128
|
|
|
); |
|
129
|
1 |
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @return array<int, string> |
|
133
|
|
|
*/ |
|
134
|
6 |
|
public function GetLine() : array |
|
135
|
|
|
{ |
|
136
|
|
|
/** |
|
137
|
|
|
* @var array<int, string> |
|
138
|
|
|
*/ |
|
139
|
6 |
|
$out = TypeUtilities::ExpectRetrievedValueIsArray( |
|
140
|
6 |
|
'line', |
|
141
|
6 |
|
$this->RetrievePropertyValueFromData('line'), |
|
142
|
6 |
|
static::class |
|
143
|
|
|
); |
|
144
|
|
|
|
|
145
|
6 |
|
return $out; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* @param array<int, string> $value |
|
150
|
|
|
*/ |
|
151
|
1 |
|
public function SetLine(array $value) : void |
|
152
|
|
|
{ |
|
153
|
1 |
|
$this->NudgePropertyWithUniqueTrimmedStringsMightNotBeString( |
|
154
|
1 |
|
'line', |
|
155
|
1 |
|
__METHOD__, |
|
156
|
1 |
|
$value |
|
157
|
|
|
); |
|
158
|
1 |
|
} |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* @return array<int, string> |
|
162
|
|
|
*/ |
|
163
|
6 |
|
public function GetPolygon() : array |
|
164
|
|
|
{ |
|
165
|
|
|
/** |
|
166
|
|
|
* @var array<int, string> |
|
167
|
|
|
*/ |
|
168
|
6 |
|
$out = TypeUtilities::ExpectRetrievedValueIsArray( |
|
169
|
6 |
|
'polygon', |
|
170
|
6 |
|
$this->RetrievePropertyValueFromData('polygon'), |
|
171
|
6 |
|
static::class |
|
172
|
|
|
); |
|
173
|
|
|
|
|
174
|
6 |
|
return $out; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* @param array<int, string> $value |
|
179
|
|
|
*/ |
|
180
|
1 |
|
public function SetPolygon(array $value) : void |
|
181
|
|
|
{ |
|
182
|
1 |
|
$this->NudgePropertyWithUniqueTrimmedStringsMightNotBeString( |
|
183
|
1 |
|
'polygon', |
|
184
|
1 |
|
__METHOD__, |
|
185
|
1 |
|
$value |
|
186
|
|
|
); |
|
187
|
1 |
|
} |
|
188
|
|
|
} |
|
189
|
|
|
|