1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Ivory Google Map package. |
5
|
|
|
* |
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ivory\GoogleMap\Service\Place\Base; |
13
|
|
|
|
14
|
|
|
use Ivory\GoogleMap\Service\Base\AddressComponent; |
15
|
|
|
use Ivory\GoogleMap\Service\Base\Geometry; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author GeLo <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class Place |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var string|null |
24
|
|
|
*/ |
25
|
|
|
private $id; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string|null |
29
|
|
|
*/ |
30
|
|
|
private $placeId; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string|null |
34
|
|
|
*/ |
35
|
|
|
private $name; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string|null |
39
|
|
|
*/ |
40
|
|
|
private $formattedAddress; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string|null |
44
|
|
|
*/ |
45
|
|
|
private $formattedPhoneNumber; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string|null |
49
|
|
|
*/ |
50
|
|
|
private $internationalPhoneNumber; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var string|null |
54
|
|
|
*/ |
55
|
|
|
private $url; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var string|null |
59
|
|
|
*/ |
60
|
|
|
private $icon; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var string|null |
64
|
|
|
*/ |
65
|
|
|
private $scope; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var int|null |
69
|
|
|
*/ |
70
|
|
|
private $priceLevel; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @var float|null |
74
|
|
|
*/ |
75
|
|
|
private $rating; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @var int|null |
79
|
|
|
*/ |
80
|
|
|
private $utcOffset; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @var string|null |
84
|
|
|
*/ |
85
|
|
|
private $vicinity; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @var string|null |
89
|
|
|
*/ |
90
|
|
|
private $website; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @var Geometry|null |
94
|
|
|
*/ |
95
|
|
|
private $geometry; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @var OpeningHours|null |
99
|
|
|
*/ |
100
|
|
|
private $openingHours; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @var AddressComponent[] |
104
|
|
|
*/ |
105
|
|
|
private $addressComponents = []; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @var Photo[] |
109
|
|
|
*/ |
110
|
|
|
private $photos = []; |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @var AlternatePlaceId[] |
114
|
|
|
*/ |
115
|
|
|
private $alternatePlaceIds = []; |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @var Review[] |
119
|
|
|
*/ |
120
|
|
|
private $reviews = []; |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @var string[] |
124
|
|
|
*/ |
125
|
|
|
private $types = []; |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @var bool|null |
129
|
|
|
*/ |
130
|
|
|
private $permanentlyClose; |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return bool |
134
|
|
|
*/ |
135
|
8 |
|
public function hasId() |
136
|
|
|
{ |
137
|
8 |
|
return null !== $this->id; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return string|null |
142
|
|
|
*/ |
143
|
8 |
|
public function getId() |
144
|
|
|
{ |
145
|
8 |
|
return $this->id; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param string|null $id |
150
|
|
|
*/ |
151
|
4 |
|
public function setId($id) |
152
|
|
|
{ |
153
|
4 |
|
$this->id = $id; |
154
|
4 |
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return bool |
158
|
|
|
*/ |
159
|
8 |
|
public function hasPlaceId() |
160
|
|
|
{ |
161
|
8 |
|
return null !== $this->placeId; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @return string|null |
166
|
|
|
*/ |
167
|
8 |
|
public function getPlaceId() |
168
|
|
|
{ |
169
|
8 |
|
return $this->placeId; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @param string|null $placeId |
174
|
|
|
*/ |
175
|
4 |
|
public function setPlaceId($placeId) |
176
|
|
|
{ |
177
|
4 |
|
$this->placeId = $placeId; |
178
|
4 |
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @return bool |
182
|
|
|
*/ |
183
|
8 |
|
public function hasName() |
184
|
|
|
{ |
185
|
8 |
|
return null !== $this->name; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @return string|null |
190
|
|
|
*/ |
191
|
8 |
|
public function getName() |
192
|
|
|
{ |
193
|
8 |
|
return $this->name; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @param string|null $name |
198
|
|
|
*/ |
199
|
4 |
|
public function setName($name) |
200
|
|
|
{ |
201
|
4 |
|
$this->name = $name; |
202
|
4 |
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return bool |
206
|
|
|
*/ |
207
|
8 |
|
public function hasFormattedAddress() |
208
|
|
|
{ |
209
|
8 |
|
return null !== $this->formattedAddress; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @return string|null |
214
|
|
|
*/ |
215
|
8 |
|
public function getFormattedAddress() |
216
|
|
|
{ |
217
|
8 |
|
return $this->formattedAddress; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @param string|null $formattedAddress |
222
|
|
|
*/ |
223
|
4 |
|
public function setFormattedAddress($formattedAddress) |
224
|
|
|
{ |
225
|
4 |
|
$this->formattedAddress = $formattedAddress; |
226
|
4 |
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @return bool |
230
|
|
|
*/ |
231
|
8 |
|
public function hasFormattedPhoneNumber() |
232
|
|
|
{ |
233
|
8 |
|
return null !== $this->formattedPhoneNumber; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @return string|null |
238
|
|
|
*/ |
239
|
8 |
|
public function getFormattedPhoneNumber() |
240
|
|
|
{ |
241
|
8 |
|
return $this->formattedPhoneNumber; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @param string|null $formattedPhoneNumber |
246
|
|
|
*/ |
247
|
4 |
|
public function setFormattedPhoneNumber($formattedPhoneNumber) |
248
|
|
|
{ |
249
|
4 |
|
$this->formattedPhoneNumber = $formattedPhoneNumber; |
250
|
4 |
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @return bool |
254
|
|
|
*/ |
255
|
8 |
|
public function hasInternationalPhoneNumber() |
256
|
|
|
{ |
257
|
8 |
|
return null !== $this->internationalPhoneNumber; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* @return string|null |
262
|
|
|
*/ |
263
|
8 |
|
public function getInternationalPhoneNumber() |
264
|
|
|
{ |
265
|
8 |
|
return $this->internationalPhoneNumber; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @param string|null $internationalPhoneNumber |
270
|
|
|
*/ |
271
|
4 |
|
public function setInternationalPhoneNumber($internationalPhoneNumber) |
272
|
|
|
{ |
273
|
4 |
|
$this->internationalPhoneNumber = $internationalPhoneNumber; |
274
|
4 |
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @return bool |
278
|
|
|
*/ |
279
|
8 |
|
public function hasUrl() |
280
|
|
|
{ |
281
|
8 |
|
return null !== $this->url; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* @return string|null |
286
|
|
|
*/ |
287
|
8 |
|
public function getUrl() |
288
|
|
|
{ |
289
|
8 |
|
return $this->url; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* @param string|null $url |
294
|
|
|
*/ |
295
|
4 |
|
public function setUrl($url) |
296
|
|
|
{ |
297
|
4 |
|
$this->url = $url; |
298
|
4 |
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* @return bool |
302
|
|
|
*/ |
303
|
8 |
|
public function hasIcon() |
304
|
|
|
{ |
305
|
8 |
|
return null !== $this->icon; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
/** |
309
|
|
|
* @return string|null |
310
|
|
|
*/ |
311
|
8 |
|
public function getIcon() |
312
|
|
|
{ |
313
|
8 |
|
return $this->icon; |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* @param string|null $icon |
318
|
|
|
*/ |
319
|
4 |
|
public function setIcon($icon) |
320
|
|
|
{ |
321
|
4 |
|
$this->icon = $icon; |
322
|
4 |
|
} |
323
|
|
|
|
324
|
|
|
/** |
325
|
|
|
* @return bool |
326
|
|
|
*/ |
327
|
8 |
|
public function hasScope() |
328
|
|
|
{ |
329
|
8 |
|
return null !== $this->scope; |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
/** |
333
|
|
|
* @return string|null |
334
|
|
|
*/ |
335
|
8 |
|
public function getScope() |
336
|
|
|
{ |
337
|
8 |
|
return $this->scope; |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* @param string|null $scope |
342
|
|
|
*/ |
343
|
4 |
|
public function setScope($scope) |
344
|
|
|
{ |
345
|
4 |
|
$this->scope = $scope; |
346
|
4 |
|
} |
347
|
|
|
|
348
|
|
|
/** |
349
|
|
|
* @return bool |
350
|
|
|
*/ |
351
|
8 |
|
public function hasPriceLevel() |
352
|
|
|
{ |
353
|
8 |
|
return null !== $this->priceLevel; |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
/** |
357
|
|
|
* @return int|null |
358
|
|
|
*/ |
359
|
8 |
|
public function getPriceLevel() |
360
|
|
|
{ |
361
|
8 |
|
return $this->priceLevel; |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* @param int|null $priceLevel |
366
|
|
|
*/ |
367
|
4 |
|
public function setPriceLevel($priceLevel) |
368
|
|
|
{ |
369
|
4 |
|
$this->priceLevel = $priceLevel; |
370
|
4 |
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* @return bool |
374
|
|
|
*/ |
375
|
8 |
|
public function hasRating() |
376
|
|
|
{ |
377
|
8 |
|
return null !== $this->rating; |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
/** |
381
|
|
|
* @return float|null |
382
|
|
|
*/ |
383
|
8 |
|
public function getRating() |
384
|
|
|
{ |
385
|
8 |
|
return $this->rating; |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
/** |
389
|
|
|
* @param float|null $rating |
390
|
|
|
*/ |
391
|
4 |
|
public function setRating($rating) |
392
|
|
|
{ |
393
|
4 |
|
$this->rating = $rating; |
394
|
4 |
|
} |
395
|
|
|
|
396
|
|
|
/** |
397
|
|
|
* @return bool |
398
|
|
|
*/ |
399
|
8 |
|
public function hasUtcOffset() |
400
|
|
|
{ |
401
|
8 |
|
return null !== $this->utcOffset; |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
/** |
405
|
|
|
* @return int|null |
406
|
|
|
*/ |
407
|
8 |
|
public function getUtcOffset() |
408
|
|
|
{ |
409
|
8 |
|
return $this->utcOffset; |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
/** |
413
|
|
|
* @param int|null $utcOffset |
414
|
|
|
*/ |
415
|
4 |
|
public function setUtcOffset($utcOffset) |
416
|
|
|
{ |
417
|
4 |
|
$this->utcOffset = $utcOffset; |
418
|
4 |
|
} |
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* @return bool |
422
|
|
|
*/ |
423
|
8 |
|
public function hasVicinity() |
424
|
|
|
{ |
425
|
8 |
|
return null !== $this->vicinity; |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
/** |
429
|
|
|
* @return string|null |
430
|
|
|
*/ |
431
|
8 |
|
public function getVicinity() |
432
|
|
|
{ |
433
|
8 |
|
return $this->vicinity; |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/** |
437
|
|
|
* @param string|null $vicinity |
438
|
|
|
*/ |
439
|
4 |
|
public function setVicinity($vicinity) |
440
|
|
|
{ |
441
|
4 |
|
$this->vicinity = $vicinity; |
442
|
4 |
|
} |
443
|
|
|
|
444
|
|
|
/** |
445
|
|
|
* @return bool |
446
|
|
|
*/ |
447
|
8 |
|
public function hasWebsite() |
448
|
|
|
{ |
449
|
8 |
|
return null !== $this->website; |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
/** |
453
|
|
|
* @return string|null |
454
|
|
|
*/ |
455
|
8 |
|
public function getWebsite() |
456
|
|
|
{ |
457
|
8 |
|
return $this->website; |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
/** |
461
|
|
|
* @param string|null $website |
462
|
|
|
*/ |
463
|
4 |
|
public function setWebsite($website) |
464
|
|
|
{ |
465
|
4 |
|
$this->website = $website; |
466
|
4 |
|
} |
467
|
|
|
|
468
|
|
|
/** |
469
|
|
|
* @return bool |
470
|
|
|
*/ |
471
|
8 |
|
public function hasGeometry() |
472
|
|
|
{ |
473
|
8 |
|
return null !== $this->geometry; |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
/** |
477
|
|
|
* @return Geometry|null |
478
|
|
|
*/ |
479
|
8 |
|
public function getGeometry() |
480
|
|
|
{ |
481
|
8 |
|
return $this->geometry; |
482
|
|
|
} |
483
|
|
|
|
484
|
4 |
|
public function setGeometry(Geometry $geometry = null) |
485
|
|
|
{ |
486
|
4 |
|
$this->geometry = $geometry; |
487
|
4 |
|
} |
488
|
|
|
|
489
|
|
|
/** |
490
|
|
|
* @return bool |
491
|
|
|
*/ |
492
|
8 |
|
public function hasOpeningHours() |
493
|
|
|
{ |
494
|
8 |
|
return null !== $this->openingHours; |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
/** |
498
|
|
|
* @return OpeningHours|null |
499
|
|
|
*/ |
500
|
8 |
|
public function getOpeningHours() |
501
|
|
|
{ |
502
|
8 |
|
return $this->openingHours; |
503
|
|
|
} |
504
|
|
|
|
505
|
4 |
|
public function setOpeningHours(OpeningHours $openingHours = null) |
506
|
|
|
{ |
507
|
4 |
|
$this->openingHours = $openingHours; |
508
|
4 |
|
} |
509
|
|
|
|
510
|
|
|
/** |
511
|
|
|
* @param string|null $type |
512
|
|
|
* |
513
|
|
|
* @return bool |
514
|
|
|
*/ |
515
|
24 |
|
public function hasAddressComponents($type = null) |
516
|
|
|
{ |
517
|
24 |
|
$addresses = $this->getAddressComponents($type); |
518
|
|
|
|
519
|
24 |
|
return !empty($addresses); |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* @param string|null $type |
524
|
|
|
* |
525
|
|
|
* @return AddressComponent[] |
526
|
|
|
*/ |
527
|
24 |
View Code Duplication |
public function getAddressComponents($type = null) |
|
|
|
|
528
|
|
|
{ |
529
|
24 |
|
if (null === $type) { |
530
|
20 |
|
return $this->addressComponents; |
531
|
|
|
} |
532
|
|
|
|
533
|
4 |
|
$addressComponents = []; |
534
|
|
|
|
535
|
4 |
|
foreach ($this->addressComponents as $addressComponent) { |
536
|
4 |
|
if (in_array($type, $addressComponent->getTypes(), true)) { |
537
|
4 |
|
$addressComponents[] = $addressComponent; |
538
|
|
|
} |
539
|
|
|
} |
540
|
|
|
|
541
|
4 |
|
return $addressComponents; |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
/** |
545
|
|
|
* @param AddressComponent[] $addressComponents |
546
|
|
|
*/ |
547
|
12 |
|
public function setAddressComponents(array $addressComponents) |
548
|
|
|
{ |
549
|
12 |
|
$this->addressComponents = []; |
550
|
12 |
|
$this->addAddressComponents($addressComponents); |
551
|
12 |
|
} |
552
|
|
|
|
553
|
|
|
/** |
554
|
|
|
* @param AddressComponent[] $addressComponents |
555
|
|
|
*/ |
556
|
12 |
|
public function addAddressComponents(array $addressComponents) |
557
|
|
|
{ |
558
|
12 |
|
foreach ($addressComponents as $addressComponent) { |
559
|
12 |
|
$this->addAddressComponent($addressComponent); |
560
|
|
|
} |
561
|
12 |
|
} |
562
|
|
|
|
563
|
|
|
/** |
564
|
|
|
* @return bool |
565
|
|
|
*/ |
566
|
20 |
|
public function hasAddressComponent(AddressComponent $addressComponent) |
567
|
|
|
{ |
568
|
20 |
|
return in_array($addressComponent, $this->addressComponents, true); |
569
|
|
|
} |
570
|
|
|
|
571
|
20 |
|
public function addAddressComponent(AddressComponent $addressComponent) |
572
|
|
|
{ |
573
|
20 |
|
if (!$this->hasAddressComponent($addressComponent)) { |
574
|
20 |
|
$this->addressComponents[] = $addressComponent; |
575
|
|
|
} |
576
|
20 |
|
} |
577
|
|
|
|
578
|
4 |
|
public function removeAddressComponent(AddressComponent $addressComponent) |
579
|
|
|
{ |
580
|
4 |
|
unset($this->addressComponents[array_search($addressComponent, $this->addressComponents, true)]); |
581
|
4 |
|
$this->addressComponents = empty($this->addressComponents) ? [] : array_values($this->addressComponents); |
582
|
4 |
|
} |
583
|
|
|
|
584
|
|
|
/** |
585
|
|
|
* @return bool |
586
|
|
|
*/ |
587
|
20 |
|
public function hasPhotos() |
588
|
|
|
{ |
589
|
20 |
|
return !empty($this->photos); |
590
|
|
|
} |
591
|
|
|
|
592
|
|
|
/** |
593
|
|
|
* @return Photo[] |
594
|
|
|
*/ |
595
|
20 |
|
public function getPhotos() |
596
|
|
|
{ |
597
|
20 |
|
return $this->photos; |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
/** |
601
|
|
|
* @param Photo[] $photos |
602
|
|
|
*/ |
603
|
8 |
|
public function setPhotos(array $photos) |
604
|
|
|
{ |
605
|
8 |
|
$this->photos = []; |
606
|
8 |
|
$this->addPhotos($photos); |
607
|
8 |
|
} |
608
|
|
|
|
609
|
|
|
/** |
610
|
|
|
* @param Photo[] $photos |
611
|
|
|
*/ |
612
|
8 |
|
public function addPhotos(array $photos) |
613
|
|
|
{ |
614
|
8 |
|
foreach ($photos as $photo) { |
615
|
8 |
|
$this->addPhoto($photo); |
616
|
|
|
} |
617
|
8 |
|
} |
618
|
|
|
|
619
|
|
|
/** |
620
|
|
|
* @return bool |
621
|
|
|
*/ |
622
|
16 |
|
public function hasPhoto(Photo $photo) |
623
|
|
|
{ |
624
|
16 |
|
return in_array($photo, $this->photos, true); |
625
|
|
|
} |
626
|
|
|
|
627
|
16 |
|
public function addPhoto(Photo $photo) |
628
|
|
|
{ |
629
|
16 |
|
if (!$this->hasPhoto($photo)) { |
630
|
16 |
|
$this->photos[] = $photo; |
631
|
|
|
} |
632
|
16 |
|
} |
633
|
|
|
|
634
|
4 |
|
public function removePhoto(Photo $photo) |
635
|
|
|
{ |
636
|
4 |
|
unset($this->photos[array_search($photo, $this->photos, true)]); |
637
|
4 |
|
$this->photos = empty($this->photos) ? [] : array_values($this->photos); |
638
|
4 |
|
} |
639
|
|
|
|
640
|
|
|
/** |
641
|
|
|
* @return bool |
642
|
|
|
*/ |
643
|
20 |
|
public function hasAlternatePlaceIds() |
644
|
|
|
{ |
645
|
20 |
|
return !empty($this->alternatePlaceIds); |
646
|
|
|
} |
647
|
|
|
|
648
|
|
|
/** |
649
|
|
|
* @return AlternatePlaceId[] |
650
|
|
|
*/ |
651
|
20 |
|
public function getAlternatePlaceIds() |
652
|
|
|
{ |
653
|
20 |
|
return $this->alternatePlaceIds; |
654
|
|
|
} |
655
|
|
|
|
656
|
|
|
/** |
657
|
|
|
* @param AlternatePlaceId[] $alternatePlaceIds |
658
|
|
|
*/ |
659
|
8 |
|
public function setAlternatePlaceIds(array $alternatePlaceIds) |
660
|
|
|
{ |
661
|
8 |
|
$this->alternatePlaceIds = []; |
662
|
8 |
|
$this->addAlternatePlaceIds($alternatePlaceIds); |
663
|
8 |
|
} |
664
|
|
|
|
665
|
|
|
/** |
666
|
|
|
* @param AlternatePlaceId[] $alternatePlaceIds |
667
|
|
|
*/ |
668
|
8 |
|
public function addAlternatePlaceIds(array $alternatePlaceIds) |
669
|
|
|
{ |
670
|
8 |
|
foreach ($alternatePlaceIds as $alternatePlaceId) { |
671
|
8 |
|
$this->addAlternatePlaceId($alternatePlaceId); |
672
|
|
|
} |
673
|
8 |
|
} |
674
|
|
|
|
675
|
|
|
/** |
676
|
|
|
* @return bool |
677
|
|
|
*/ |
678
|
16 |
|
public function hasAlternatePlaceId(AlternatePlaceId $alternatePlaceId) |
679
|
|
|
{ |
680
|
16 |
|
return in_array($alternatePlaceId, $this->alternatePlaceIds, true); |
681
|
|
|
} |
682
|
|
|
|
683
|
16 |
|
public function addAlternatePlaceId(AlternatePlaceId $alternatePlaceId) |
684
|
|
|
{ |
685
|
16 |
|
if (!$this->hasAlternatePlaceId($alternatePlaceId)) { |
686
|
16 |
|
$this->alternatePlaceIds[] = $alternatePlaceId; |
687
|
|
|
} |
688
|
16 |
|
} |
689
|
|
|
|
690
|
4 |
|
public function removeAlternatePlaceId(AlternatePlaceId $alternatePlaceId) |
691
|
|
|
{ |
692
|
4 |
|
unset($this->alternatePlaceIds[array_search($alternatePlaceId, $this->alternatePlaceIds, true)]); |
693
|
4 |
|
$this->alternatePlaceIds = empty($this->alternatePlaceIds) ? [] : array_values($this->alternatePlaceIds); |
694
|
4 |
|
} |
695
|
|
|
|
696
|
|
|
/** |
697
|
|
|
* @return bool |
698
|
|
|
*/ |
699
|
20 |
|
public function hasReviews() |
700
|
|
|
{ |
701
|
20 |
|
return !empty($this->reviews); |
702
|
|
|
} |
703
|
|
|
|
704
|
|
|
/** |
705
|
|
|
* @return Review[] |
706
|
|
|
*/ |
707
|
20 |
|
public function getReviews() |
708
|
|
|
{ |
709
|
20 |
|
return $this->reviews; |
710
|
|
|
} |
711
|
|
|
|
712
|
|
|
/** |
713
|
|
|
* @param Review[] $reviews |
714
|
|
|
*/ |
715
|
8 |
|
public function setReviews(array $reviews) |
716
|
|
|
{ |
717
|
8 |
|
$this->reviews = []; |
718
|
8 |
|
$this->addReviews($reviews); |
719
|
8 |
|
} |
720
|
|
|
|
721
|
|
|
/** |
722
|
|
|
* @param Review[] $reviews |
723
|
|
|
*/ |
724
|
8 |
|
public function addReviews(array $reviews) |
725
|
|
|
{ |
726
|
8 |
|
foreach ($reviews as $review) { |
727
|
8 |
|
$this->addReview($review); |
728
|
|
|
} |
729
|
8 |
|
} |
730
|
|
|
|
731
|
|
|
/** |
732
|
|
|
* @return bool |
733
|
|
|
*/ |
734
|
16 |
|
public function hasReview(Review $review) |
735
|
|
|
{ |
736
|
16 |
|
return in_array($review, $this->reviews, true); |
737
|
|
|
} |
738
|
|
|
|
739
|
16 |
|
public function addReview(Review $review) |
740
|
|
|
{ |
741
|
16 |
|
if (!$this->hasReview($review)) { |
742
|
16 |
|
$this->reviews[] = $review; |
743
|
|
|
} |
744
|
16 |
|
} |
745
|
|
|
|
746
|
4 |
|
public function removeReview(Review $review) |
747
|
|
|
{ |
748
|
4 |
|
unset($this->reviews[array_search($review, $this->reviews, true)]); |
749
|
4 |
|
$this->reviews = empty($this->reviews) ? [] : array_values($this->reviews); |
750
|
4 |
|
} |
751
|
|
|
|
752
|
|
|
/** |
753
|
|
|
* @return bool |
754
|
|
|
*/ |
755
|
20 |
|
public function hasTypes() |
756
|
|
|
{ |
757
|
20 |
|
return !empty($this->types); |
758
|
|
|
} |
759
|
|
|
|
760
|
|
|
/** |
761
|
|
|
* @return string[] |
762
|
|
|
*/ |
763
|
20 |
|
public function getTypes() |
764
|
|
|
{ |
765
|
20 |
|
return $this->types; |
766
|
|
|
} |
767
|
|
|
|
768
|
|
|
/** |
769
|
|
|
* @param string[] $types |
770
|
|
|
*/ |
771
|
8 |
|
public function setTypes(array $types) |
772
|
|
|
{ |
773
|
8 |
|
$this->types = []; |
774
|
8 |
|
$this->addTypes($types); |
775
|
8 |
|
} |
776
|
|
|
|
777
|
|
|
/** |
778
|
|
|
* @param string[] $types |
779
|
|
|
*/ |
780
|
8 |
|
public function addTypes(array $types) |
781
|
|
|
{ |
782
|
8 |
|
foreach ($types as $type) { |
783
|
8 |
|
$this->addType($type); |
784
|
|
|
} |
785
|
8 |
|
} |
786
|
|
|
|
787
|
|
|
/** |
788
|
|
|
* @param string $type |
789
|
|
|
* |
790
|
|
|
* @return bool |
791
|
|
|
*/ |
792
|
16 |
|
public function hasType($type) |
793
|
|
|
{ |
794
|
16 |
|
return in_array($type, $this->types, true); |
795
|
|
|
} |
796
|
|
|
|
797
|
|
|
/** |
798
|
|
|
* @param string $type |
799
|
|
|
*/ |
800
|
16 |
|
public function addType($type) |
801
|
|
|
{ |
802
|
16 |
|
if (!$this->hasType($type)) { |
803
|
16 |
|
$this->types[] = $type; |
804
|
|
|
} |
805
|
16 |
|
} |
806
|
|
|
|
807
|
|
|
/** |
808
|
|
|
* @param string $type |
809
|
|
|
*/ |
810
|
4 |
|
public function removeType($type) |
811
|
|
|
{ |
812
|
4 |
|
unset($this->types[array_search($type, $this->types, true)]); |
813
|
4 |
|
$this->types = empty($this->types) ? [] : array_values($this->types); |
814
|
4 |
|
} |
815
|
|
|
|
816
|
|
|
/** |
817
|
|
|
* @return bool |
818
|
|
|
*/ |
819
|
8 |
|
public function hasPermanentlyClose() |
820
|
|
|
{ |
821
|
8 |
|
return null !== $this->permanentlyClose; |
822
|
|
|
} |
823
|
|
|
|
824
|
|
|
/** |
825
|
|
|
* @return bool|null |
826
|
|
|
*/ |
827
|
8 |
|
public function isPermanentlyClose() |
828
|
|
|
{ |
829
|
8 |
|
return $this->permanentlyClose; |
830
|
|
|
} |
831
|
|
|
|
832
|
|
|
/** |
833
|
|
|
* @param bool|null $permanentlyClose |
834
|
|
|
*/ |
835
|
4 |
|
public function setPermanentlyClose($permanentlyClose) |
836
|
|
|
{ |
837
|
4 |
|
$this->permanentlyClose = $permanentlyClose; |
838
|
4 |
|
} |
839
|
|
|
} |
840
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.