geocoder-php /
google-maps-places-provider
| 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\GoogleMapsPlaces\Model; |
||
| 14 | |||
| 15 | use Geocoder\Model\Address; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @author atymic <[email protected]> |
||
| 19 | */ |
||
| 20 | final class GooglePlace extends Address |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var string|null |
||
| 24 | */ |
||
| 25 | private $id; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var string|null |
||
| 29 | */ |
||
| 30 | private $name; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var array |
||
| 34 | */ |
||
| 35 | private $type = []; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var string|null |
||
| 39 | */ |
||
| 40 | private $formattedAddress; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var string|null |
||
| 44 | */ |
||
| 45 | private $vicinity; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var string|null |
||
| 49 | */ |
||
| 50 | private $icon; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var PlusCode|null |
||
| 54 | */ |
||
| 55 | private $plusCode; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var Photo[]|null |
||
| 59 | */ |
||
| 60 | private $photos; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @var int|null |
||
| 64 | */ |
||
| 65 | private $priceLevel; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @var float|null |
||
| 69 | */ |
||
| 70 | private $rating; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @var string|null |
||
| 74 | */ |
||
| 75 | private $formattedPhoneNumber; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @var string|null |
||
| 79 | */ |
||
| 80 | private $internationalPhoneNumber; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @var string|null |
||
| 84 | */ |
||
| 85 | private $website; |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @var OpeningHours |
||
| 89 | */ |
||
| 90 | private $openingHours; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @var bool |
||
| 94 | */ |
||
| 95 | private $permanentlyClosed = false; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @see https://developers.google.com/places/place-id |
||
| 99 | * |
||
| 100 | * @return string|null |
||
| 101 | */ |
||
| 102 | public function getId() |
||
| 103 | { |
||
| 104 | return $this->id; |
||
| 105 | } |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @param string|null $id |
||
| 109 | * |
||
| 110 | * @return GooglePlace |
||
| 111 | */ |
||
| 112 | public function withId(string $id = null) |
||
| 113 | { |
||
| 114 | $new = clone $this; |
||
| 115 | $new->id = $id; |
||
| 116 | |||
| 117 | return $new; |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @return string|null |
||
| 122 | */ |
||
| 123 | public function getName() |
||
| 124 | { |
||
| 125 | return $this->name; |
||
| 126 | } |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @param string|null $name |
||
| 130 | * |
||
| 131 | * @return GooglePlace |
||
| 132 | */ |
||
| 133 | public function withName(string $name = null) |
||
| 134 | { |
||
| 135 | $new = clone $this; |
||
| 136 | $new->name = $name; |
||
| 137 | |||
| 138 | return $new; |
||
| 139 | } |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @return array |
||
| 143 | */ |
||
| 144 | public function getType(): array |
||
| 145 | { |
||
| 146 | return $this->type; |
||
| 147 | } |
||
| 148 | |||
| 149 | /** |
||
| 150 | * @param array $type |
||
| 151 | * |
||
| 152 | * @return GooglePlace |
||
| 153 | */ |
||
| 154 | public function withType(array $type) |
||
| 155 | { |
||
| 156 | $new = clone $this; |
||
| 157 | $new->type = $type; |
||
| 158 | |||
| 159 | return $new; |
||
| 160 | } |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @return string|null |
||
| 164 | */ |
||
| 165 | public function getFormattedAddress() |
||
| 166 | { |
||
| 167 | return $this->formattedAddress; |
||
| 168 | } |
||
| 169 | |||
| 170 | /** |
||
| 171 | * @param string|null $formattedAddress |
||
| 172 | * |
||
| 173 | * @return GooglePlace |
||
| 174 | */ |
||
| 175 | public function withFormattedAddress(string $formattedAddress = null) |
||
| 176 | { |
||
| 177 | $new = clone $this; |
||
| 178 | $new->formattedAddress = $formattedAddress; |
||
| 179 | |||
| 180 | return $new; |
||
| 181 | } |
||
| 182 | |||
| 183 | /** |
||
| 184 | * @return string|null |
||
| 185 | */ |
||
| 186 | public function getVicinity() |
||
| 187 | { |
||
| 188 | return $this->vicinity; |
||
| 189 | } |
||
| 190 | |||
| 191 | /** |
||
| 192 | * @param string|null $vicinity |
||
| 193 | * |
||
| 194 | * @return GooglePlace |
||
| 195 | */ |
||
| 196 | public function withVicinity(string $vicinity = null) |
||
| 197 | { |
||
| 198 | $new = clone $this; |
||
| 199 | $new->vicinity = $vicinity; |
||
| 200 | |||
| 201 | return $new; |
||
| 202 | } |
||
| 203 | |||
| 204 | /** |
||
| 205 | * @return string|null |
||
| 206 | */ |
||
| 207 | public function getIcon(): string |
||
| 208 | { |
||
| 209 | return $this->icon; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 210 | } |
||
| 211 | |||
| 212 | public function withIcon(string $icon = null) |
||
| 213 | { |
||
| 214 | $new = clone $this; |
||
| 215 | $new->icon = $icon; |
||
| 216 | |||
| 217 | return $new; |
||
| 218 | } |
||
| 219 | |||
| 220 | /** |
||
| 221 | * @return PlusCode|null |
||
| 222 | */ |
||
| 223 | public function getPlusCode(): ?PlusCode |
||
| 224 | { |
||
| 225 | return $this->plusCode; |
||
| 226 | } |
||
| 227 | |||
| 228 | public function withPlusCode(PlusCode $plusCode = null) |
||
| 229 | { |
||
| 230 | $new = clone $this; |
||
| 231 | $new->plusCode = $plusCode; |
||
| 232 | |||
| 233 | return $new; |
||
| 234 | } |
||
| 235 | |||
| 236 | /** |
||
| 237 | * @return Photo[]|null |
||
| 238 | */ |
||
| 239 | public function getPhotos(): array |
||
| 240 | { |
||
| 241 | return $this->photos; |
||
|
0 ignored issues
–
show
|
|||
| 242 | } |
||
| 243 | |||
| 244 | public function withPhotos(array $photos = null) |
||
| 245 | { |
||
| 246 | $new = clone $this; |
||
| 247 | $new->photos = $photos; |
||
| 248 | |||
| 249 | return $new; |
||
| 250 | } |
||
| 251 | |||
| 252 | /** |
||
| 253 | * @see https://developers.google.com/places/web-service/search#find-place-responses |
||
| 254 | * |
||
| 255 | * 0 — Free |
||
| 256 | * 1 — Inexpensive |
||
| 257 | * 2 — Moderate |
||
| 258 | * 3 — Expensive |
||
| 259 | * 4 — Very Expensive |
||
| 260 | * |
||
| 261 | * @return int|null |
||
| 262 | */ |
||
| 263 | public function getPriceLevel(): int |
||
| 264 | { |
||
| 265 | return $this->priceLevel; |
||
|
0 ignored issues
–
show
|
|||
| 266 | } |
||
| 267 | |||
| 268 | public function withPriceLevel(int $priceLevel = null) |
||
| 269 | { |
||
| 270 | $new = clone $this; |
||
| 271 | $new->priceLevel = $priceLevel; |
||
| 272 | |||
| 273 | return $new; |
||
| 274 | } |
||
| 275 | |||
| 276 | /** |
||
| 277 | * @return float|null |
||
| 278 | */ |
||
| 279 | public function getRating(): float |
||
| 280 | { |
||
| 281 | return $this->rating; |
||
|
0 ignored issues
–
show
|
|||
| 282 | } |
||
| 283 | |||
| 284 | public function withRating(float $rating = null) |
||
| 285 | { |
||
| 286 | $new = clone $this; |
||
| 287 | $new->rating = $rating; |
||
| 288 | |||
| 289 | return $new; |
||
| 290 | } |
||
| 291 | |||
| 292 | /** |
||
| 293 | * @return string|null |
||
| 294 | */ |
||
| 295 | public function getFormattedPhoneNumber() |
||
| 296 | { |
||
| 297 | return $this->formattedPhoneNumber; |
||
| 298 | } |
||
| 299 | |||
| 300 | public function withFormattedPhoneNumber(string $phone) |
||
| 301 | { |
||
| 302 | $new = clone $this; |
||
| 303 | $new->formattedPhoneNumber = $phone; |
||
| 304 | |||
| 305 | return $new; |
||
| 306 | } |
||
| 307 | |||
| 308 | /** |
||
| 309 | * @return string|null |
||
| 310 | */ |
||
| 311 | public function getInternationalPhoneNumber() |
||
| 312 | { |
||
| 313 | return $this->internationalPhoneNumber; |
||
| 314 | } |
||
| 315 | |||
| 316 | public function withInternationalPhoneNumber(string $phone) |
||
| 317 | { |
||
| 318 | $new = clone $this; |
||
| 319 | $new->internationalPhoneNumber = $phone; |
||
| 320 | |||
| 321 | return $new; |
||
| 322 | } |
||
| 323 | |||
| 324 | /** |
||
| 325 | * @return string|null |
||
| 326 | */ |
||
| 327 | public function getWebsite() |
||
| 328 | { |
||
| 329 | return $this->website; |
||
| 330 | } |
||
| 331 | |||
| 332 | public function withWebsite(string $website) |
||
| 333 | { |
||
| 334 | $new = clone $this; |
||
| 335 | $new->website = $website; |
||
| 336 | |||
| 337 | return $new; |
||
| 338 | } |
||
| 339 | |||
| 340 | /** |
||
| 341 | * @return OpeningHours |
||
| 342 | */ |
||
| 343 | public function getOpeningHours() |
||
| 344 | { |
||
| 345 | return $this->openingHours; |
||
| 346 | } |
||
| 347 | |||
| 348 | public function withOpeningHours(OpeningHours $openingHours) |
||
| 349 | { |
||
| 350 | $new = clone $this; |
||
| 351 | $new->openingHours = $openingHours; |
||
| 352 | |||
| 353 | return $new; |
||
| 354 | } |
||
| 355 | |||
| 356 | /** |
||
| 357 | * @return bool |
||
| 358 | */ |
||
| 359 | public function isPermanentlyClosed(): bool |
||
| 360 | { |
||
| 361 | return $this->permanentlyClosed; |
||
| 362 | } |
||
| 363 | |||
| 364 | public function setPermanentlyClosed() |
||
| 365 | { |
||
| 366 | $new = clone $this; |
||
| 367 | $new->permanentlyClosed = true; |
||
| 368 | |||
| 369 | return $new; |
||
| 370 | } |
||
| 371 | } |
||
| 372 |