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 $class; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string|null |
34
|
|
|
*/ |
35
|
|
|
private $displayName; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string|null |
39
|
|
|
*/ |
40
|
|
|
private $osmType; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var int|null |
44
|
|
|
*/ |
45
|
|
|
private $osmId; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string|null |
49
|
|
|
*/ |
50
|
|
|
private $type; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return null|string |
54
|
|
|
*/ |
55
|
1 |
|
public function getAttribution() |
56
|
|
|
{ |
57
|
1 |
|
return $this->attribution; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param null|string $attribution |
62
|
|
|
* |
63
|
|
|
* @return NominatimAddress |
64
|
|
|
*/ |
65
|
5 |
|
public function withAttribution(string $attribution = null): self |
66
|
|
|
{ |
67
|
5 |
|
$new = clone $this; |
68
|
5 |
|
$new->attribution = $attribution; |
69
|
|
|
|
70
|
5 |
|
return $new; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return null|string |
75
|
|
|
*/ |
76
|
1 |
|
public function getClass() |
77
|
|
|
{ |
78
|
1 |
|
return $this->class; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param null|string $class |
83
|
|
|
* |
84
|
|
|
* @return NominatimAddress |
85
|
|
|
*/ |
86
|
3 |
|
public function withClass(string $class = null): self |
87
|
|
|
{ |
88
|
3 |
|
$new = clone $this; |
89
|
3 |
|
$new->class = $class; |
90
|
|
|
|
91
|
3 |
|
return $new; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return null|string |
96
|
|
|
*/ |
97
|
1 |
|
public function getDisplayName() |
98
|
|
|
{ |
99
|
1 |
|
return $this->displayName; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param null|string $displayName |
104
|
|
|
* |
105
|
|
|
* @return NominatimAddress |
106
|
|
|
*/ |
107
|
5 |
|
public function withDisplayName(string $displayName = null): self |
108
|
|
|
{ |
109
|
5 |
|
$new = clone $this; |
110
|
5 |
|
$new->displayName = $displayName; |
111
|
|
|
|
112
|
5 |
|
return $new; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return null|int |
117
|
|
|
*/ |
118
|
1 |
|
public function getOSMId() |
119
|
|
|
{ |
120
|
1 |
|
return $this->osmId; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param null|int $osmId |
125
|
|
|
* |
126
|
|
|
* @return NominatimAddress |
127
|
|
|
*/ |
128
|
5 |
|
public function withOSMId(int $osmId = null): self |
129
|
|
|
{ |
130
|
5 |
|
$new = clone $this; |
131
|
5 |
|
$new->osmId = $osmId; |
132
|
|
|
|
133
|
5 |
|
return $new; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return null|string |
138
|
|
|
*/ |
139
|
1 |
|
public function getOSMType() |
140
|
|
|
{ |
141
|
1 |
|
return $this->osmType; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param null|string $osmType |
146
|
|
|
* |
147
|
|
|
* @return NominatimAddress |
148
|
|
|
*/ |
149
|
5 |
|
public function withOSMType(string $osmType = null): self |
150
|
|
|
{ |
151
|
5 |
|
$new = clone $this; |
152
|
5 |
|
$new->osmType = $osmType; |
153
|
|
|
|
154
|
5 |
|
return $new; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @return null|string |
159
|
|
|
*/ |
160
|
1 |
|
public function getType() |
161
|
|
|
{ |
162
|
1 |
|
return $this->type; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @param null|string $type |
167
|
|
|
* |
168
|
|
|
* @return NominatimAddress |
169
|
|
|
*/ |
170
|
3 |
|
public function withType(string $type = null): self |
171
|
|
|
{ |
172
|
3 |
|
$new = clone $this; |
173
|
3 |
|
$new->type = $type; |
174
|
|
|
|
175
|
3 |
|
return $new; |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
|