1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Geocoder package. |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @license MIT License |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Geocoder\Provider\Nominatim\Model; |
14
|
|
|
|
15
|
|
|
use Geocoder\Model\Address; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Jonathan Beliën <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
final class NominatimAddress extends Address |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var string|null |
24
|
|
|
*/ |
25
|
|
|
private $attribution; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string|null |
29
|
|
|
*/ |
30
|
|
|
private $category; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string|null |
34
|
|
|
*/ |
35
|
|
|
private $displayName; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string|null |
39
|
|
|
*/ |
40
|
|
|
private $quarter; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string|null |
44
|
|
|
*/ |
45
|
|
|
private $osmType; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var int|null |
49
|
|
|
*/ |
50
|
|
|
private $osmId; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var string|null |
54
|
|
|
*/ |
55
|
|
|
private $type; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var array|null |
59
|
|
|
*/ |
60
|
|
|
private $details; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var array|null |
64
|
|
|
*/ |
65
|
|
|
private $tags; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return string|null |
69
|
|
|
*/ |
70
|
4 |
|
public function getAttribution() |
71
|
|
|
{ |
72
|
4 |
|
return $this->attribution; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param string|null $attribution |
77
|
|
|
* |
78
|
|
|
* @return NominatimAddress |
79
|
|
|
*/ |
80
|
10 |
|
public function withAttribution(string $attribution = null): self |
81
|
|
|
{ |
82
|
10 |
|
$new = clone $this; |
83
|
10 |
|
$new->attribution = $attribution; |
84
|
|
|
|
85
|
10 |
|
return $new; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @deprecated |
90
|
|
|
* |
91
|
|
|
* @return string|null |
92
|
|
|
*/ |
93
|
|
|
public function getClass() |
94
|
|
|
{ |
95
|
|
|
return $this->getCategory(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @deprecated |
100
|
|
|
* |
101
|
|
|
* @param string|null $category |
102
|
|
|
* |
103
|
|
|
* @return NominatimAddress |
104
|
|
|
*/ |
105
|
|
|
public function withClass(string $category = null): self |
106
|
|
|
{ |
107
|
|
|
return $this->withCategory($category); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return string|null |
112
|
|
|
*/ |
113
|
4 |
|
public function getCategory() |
114
|
|
|
{ |
115
|
4 |
|
return $this->category; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param string|null $category |
120
|
|
|
* |
121
|
|
|
* @return NominatimAddress |
122
|
|
|
*/ |
123
|
8 |
|
public function withCategory(string $category = null): self |
124
|
|
|
{ |
125
|
8 |
|
$new = clone $this; |
126
|
8 |
|
$new->category = $category; |
127
|
|
|
|
128
|
8 |
|
return $new; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return string|null |
133
|
|
|
*/ |
134
|
3 |
|
public function getDisplayName() |
135
|
|
|
{ |
136
|
3 |
|
return $this->displayName; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param string|null $displayName |
141
|
|
|
* |
142
|
|
|
* @return NominatimAddress |
143
|
|
|
*/ |
144
|
10 |
|
public function withDisplayName(string $displayName = null): self |
145
|
|
|
{ |
146
|
10 |
|
$new = clone $this; |
147
|
10 |
|
$new->displayName = $displayName; |
148
|
|
|
|
149
|
10 |
|
return $new; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @return int|null |
154
|
|
|
*/ |
155
|
4 |
|
public function getOSMId() |
156
|
|
|
{ |
157
|
4 |
|
return $this->osmId; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @param int|null $osmId |
162
|
|
|
* |
163
|
|
|
* @return NominatimAddress |
164
|
|
|
*/ |
165
|
9 |
|
public function withOSMId(int $osmId = null): self |
166
|
|
|
{ |
167
|
9 |
|
$new = clone $this; |
168
|
9 |
|
$new->osmId = $osmId; |
169
|
|
|
|
170
|
9 |
|
return $new; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @return string|null |
175
|
|
|
*/ |
176
|
4 |
|
public function getOSMType() |
177
|
|
|
{ |
178
|
4 |
|
return $this->osmType; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* @param string|null $osmType |
183
|
|
|
* |
184
|
|
|
* @return NominatimAddress |
185
|
|
|
*/ |
186
|
9 |
|
public function withOSMType(string $osmType = null): self |
187
|
|
|
{ |
188
|
9 |
|
$new = clone $this; |
189
|
9 |
|
$new->osmType = $osmType; |
190
|
|
|
|
191
|
9 |
|
return $new; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @return string|null |
196
|
|
|
*/ |
197
|
3 |
|
public function getType() |
198
|
|
|
{ |
199
|
3 |
|
return $this->type; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @param string|null $type |
204
|
|
|
* |
205
|
|
|
* @return NominatimAddress |
206
|
|
|
*/ |
207
|
8 |
|
public function withType(string $type = null): self |
208
|
|
|
{ |
209
|
8 |
|
$new = clone $this; |
210
|
8 |
|
$new->type = $type; |
211
|
|
|
|
212
|
8 |
|
return $new; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* @return string|null |
217
|
|
|
*/ |
218
|
1 |
|
public function getQuarter(): ?string |
219
|
|
|
{ |
220
|
1 |
|
return $this->quarter; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @param string|null $quarter |
225
|
|
|
* |
226
|
|
|
* @return NominatimAddress |
227
|
|
|
*/ |
228
|
2 |
|
public function withQuarter(string $quarter = null): self |
229
|
|
|
{ |
230
|
2 |
|
$new = clone $this; |
231
|
2 |
|
$new->quarter = $quarter; |
232
|
|
|
|
233
|
2 |
|
return $new; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @return array|null |
238
|
|
|
*/ |
239
|
1 |
|
public function getDetails(): ?array |
240
|
|
|
{ |
241
|
1 |
|
return $this->details; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @param array|null $details |
246
|
|
|
*/ |
247
|
10 |
|
public function withDetails(array $details = null): self |
248
|
|
|
{ |
249
|
10 |
|
$new = clone $this; |
250
|
10 |
|
$new->details = $details; |
251
|
|
|
|
252
|
10 |
|
return $new; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* @return array|null |
257
|
|
|
*/ |
258
|
1 |
|
public function getTags(): ?array |
259
|
|
|
{ |
260
|
1 |
|
return $this->tags; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* @param array|null $tags |
265
|
|
|
*/ |
266
|
8 |
|
public function withTags(array $tags = null): self |
267
|
|
|
{ |
268
|
8 |
|
$new = clone $this; |
269
|
8 |
|
$new->tags = $tags; |
270
|
|
|
|
271
|
8 |
|
return $new; |
272
|
|
|
} |
273
|
|
|
} |
274
|
|
|
|