GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — place-services ( fedba7 )
by Eric
03:31
created

Place::getVicinity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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
    public function hasId()
136
    {
137
        return $this->id !== null;
138
    }
139
140
    /**
141
     * @return string|null
142
     */
143
    public function getId()
144
    {
145
        return $this->id;
146
    }
147
148
    /**
149
     * @param string|null $id
150
     */
151
    public function setId($id)
152
    {
153
        $this->id = $id;
154
    }
155
156
    /**
157
     * @return bool
158
     */
159
    public function hasPlaceId()
160
    {
161
        return $this->placeId !== null;
162
    }
163
164
    /**
165
     * @return string|null
166
     */
167
    public function getPlaceId()
168
    {
169
        return $this->placeId;
170
    }
171
172
    /**
173
     * @param string|null $placeId
174
     */
175
    public function setPlaceId($placeId)
176
    {
177
        $this->placeId = $placeId;
178
    }
179
180
    /**
181
     * @return bool
182
     */
183
    public function hasName()
184
    {
185
        return $this->name !== null;
186
    }
187
188
    /**
189
     * @return string|null
190
     */
191
    public function getName()
192
    {
193
        return $this->name;
194
    }
195
196
    /**
197
     * @param string|null $name
198
     */
199
    public function setName($name)
200
    {
201
        $this->name = $name;
202
    }
203
204
    /**
205
     * @return bool
206
     */
207
    public function hasFormattedAddress()
208
    {
209
        return $this->formattedAddress !== null;
210
    }
211
212
    /**
213
     * @return string|null
214
     */
215
    public function getFormattedAddress()
216
    {
217
        return $this->formattedAddress;
218
    }
219
220
    /**
221
     * @param string|null $formattedAddress
222
     */
223
    public function setFormattedAddress($formattedAddress)
224
    {
225
        $this->formattedAddress = $formattedAddress;
226
    }
227
228
    /**
229
     * @return bool
230
     */
231
    public function hasFormattedPhoneNumber()
232
    {
233
        return $this->formattedPhoneNumber !== null;
234
    }
235
236
    /**
237
     * @return string|null
238
     */
239
    public function getFormattedPhoneNumber()
240
    {
241
        return $this->formattedPhoneNumber;
242
    }
243
244
    /**
245
     * @param string|null $formattedPhoneNumber
246
     */
247
    public function setFormattedPhoneNumber($formattedPhoneNumber)
248
    {
249
        $this->formattedPhoneNumber = $formattedPhoneNumber;
250
    }
251
252
    /**
253
     * @return bool
254
     */
255
    public function hasInternationalPhoneNumber()
256
    {
257
        return $this->internationalPhoneNumber !== null;
258
    }
259
260
    /**
261
     * @return string|null
262
     */
263
    public function getInternationalPhoneNumber()
264
    {
265
        return $this->internationalPhoneNumber;
266
    }
267
268
    /**
269
     * @param string|null $internationalPhoneNumber
270
     */
271
    public function setInternationalPhoneNumber($internationalPhoneNumber)
272
    {
273
        $this->internationalPhoneNumber = $internationalPhoneNumber;
274
    }
275
276
    /**
277
     * @return bool
278
     */
279
    public function hasUrl()
280
    {
281
        return $this->url !== null;
282
    }
283
284
    /**
285
     * @return string|null
286
     */
287
    public function getUrl()
288
    {
289
        return $this->url;
290
    }
291
292
    /**
293
     * @param string|null $url
294
     */
295
    public function setUrl($url)
296
    {
297
        $this->url = $url;
298
    }
299
300
    /**
301
     * @return bool
302
     */
303
    public function hasIcon()
304
    {
305
        return $this->icon !== null;
306
    }
307
308
    /**
309
     * @return string|null
310
     */
311
    public function getIcon()
312
    {
313
        return $this->icon;
314
    }
315
316
    /**
317
     * @param string|null $icon
318
     */
319
    public function setIcon($icon)
320
    {
321
        $this->icon = $icon;
322
    }
323
324
    /**
325
     * @return bool
326
     */
327
    public function hasScope()
328
    {
329
        return $this->scope !== null;
330
    }
331
332
    /**
333
     * @return string|null
334
     */
335
    public function getScope()
336
    {
337
        return $this->scope;
338
    }
339
340
    /**
341
     * @param string|null $scope
342
     */
343
    public function setScope($scope)
344
    {
345
        $this->scope = $scope;
346
    }
347
348
    /**
349
     * @return bool
350
     */
351
    public function hasPriceLevel()
352
    {
353
        return $this->priceLevel !== null;
354
    }
355
356
    /**
357
     * @return int|null
358
     */
359
    public function getPriceLevel()
360
    {
361
        return $this->priceLevel;
362
    }
363
364
    /**
365
     * @param int|null $priceLevel
366
     */
367
    public function setPriceLevel($priceLevel)
368
    {
369
        $this->priceLevel = $priceLevel;
370
    }
371
372
    /**
373
     * @return bool
374
     */
375
    public function hasRating()
376
    {
377
        return $this->rating !== null;
378
    }
379
380
    /**
381
     * @return float|null
382
     */
383
    public function getRating()
384
    {
385
        return $this->rating;
386
    }
387
388
    /**
389
     * @param float|null $rating
390
     */
391
    public function setRating($rating)
392
    {
393
        $this->rating = $rating;
394
    }
395
396
    /**
397
     * @return bool
398
     */
399
    public function hasUtcOffset()
400
    {
401
        return $this->utcOffset !== null;
402
    }
403
404
    /**
405
     * @return int|null
406
     */
407
    public function getUtcOffset()
408
    {
409
        return $this->utcOffset;
410
    }
411
412
    /**
413
     * @param int|null $utcOffset
414
     */
415
    public function setUtcOffset($utcOffset)
416
    {
417
        $this->utcOffset = $utcOffset;
418
    }
419
420
    /**
421
     * @return bool
422
     */
423
    public function hasVicinity()
424
    {
425
        return $this->vicinity !== null;
426
    }
427
428
    /**
429
     * @return string|null
430
     */
431
    public function getVicinity()
432
    {
433
        return $this->vicinity;
434
    }
435
436
    /**
437
     * @param string|null $vicinity
438
     */
439
    public function setVicinity($vicinity)
440
    {
441
        $this->vicinity = $vicinity;
442
    }
443
444
    /**
445
     * @return bool
446
     */
447
    public function hasWebsite()
448
    {
449
        return $this->website !== null;
450
    }
451
452
    /**
453
     * @return string|null
454
     */
455
    public function getWebsite()
456
    {
457
        return $this->website;
458
    }
459
460
    /**
461
     * @param string|null $website
462
     */
463
    public function setWebsite($website)
464
    {
465
        $this->website = $website;
466
    }
467
468
    /**
469
     * @return bool
470
     */
471
    public function hasGeometry()
472
    {
473
        return $this->geometry !== null;
474
    }
475
476
    /**
477
     * @return Geometry|null
478
     */
479
    public function getGeometry()
480
    {
481
        return $this->geometry;
482
    }
483
484
    /**
485
     * @param Geometry|null $geometry
486
     */
487
    public function setGeometry(Geometry $geometry = null)
488
    {
489
        $this->geometry = $geometry;
490
    }
491
492
    /**
493
     * @return bool
494
     */
495
    public function hasOpeningHours()
496
    {
497
        return $this->openingHours !== null;
498
    }
499
500
    /**
501
     * @return OpeningHours|null
502
     */
503
    public function getOpeningHours()
504
    {
505
        return $this->openingHours;
506
    }
507
508
    /**
509
     * @param OpeningHours|null $openingHours
510
     */
511
    public function setOpeningHours(OpeningHours $openingHours = null)
512
    {
513
        $this->openingHours = $openingHours;
514
    }
515
516
    /**
517
     * @param string|null $type
518
     *
519
     * @return bool
520
     */
521
    public function hasAddressComponents($type = null)
522
    {
523
        $addresses = $this->getAddressComponents($type);
524
525
        return !empty($addresses);
526
    }
527
528
    /**
529
     * @param string|null $type
530
     *
531
     * @return AddressComponent[]
532
     */
533 View Code Duplication
    public function getAddressComponents($type = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
534
    {
535
        if ($type === null) {
536
            return $this->addressComponents;
537
        }
538
539
        $addressComponents = [];
540
541
        foreach ($this->addressComponents as $addressComponent) {
542
            if (in_array($type, $addressComponent->getTypes(), true)) {
543
                $addressComponents[] = $addressComponent;
544
            }
545
        }
546
547
        return $addressComponents;
548
    }
549
550
    /**
551
     * @param AddressComponent[] $addressComponents
552
     */
553
    public function setAddressComponents(array $addressComponents)
554
    {
555
        $this->addressComponents = [];
556
        $this->addAddressComponents($addressComponents);
557
    }
558
559
    /**
560
     * @param AddressComponent[] $addressComponents
561
     */
562
    public function addAddressComponents(array $addressComponents)
563
    {
564
        foreach ($addressComponents as $addressComponent) {
565
            $this->addAddressComponent($addressComponent);
566
        }
567
    }
568
569
    /**
570
     * @param AddressComponent $addressComponent
571
     *
572
     * @return bool
573
     */
574
    public function hasAddressComponent(AddressComponent $addressComponent)
575
    {
576
        return in_array($addressComponent, $this->addressComponents, true);
577
    }
578
579
    /**
580
     * @param AddressComponent $addressComponent
581
     */
582
    public function addAddressComponent(AddressComponent $addressComponent)
583
    {
584
        if (!$this->hasAddressComponent($addressComponent)) {
585
            $this->addressComponents[] = $addressComponent;
586
        }
587
    }
588
589
    /**
590
     * @param AddressComponent $addressComponent
591
     */
592
    public function removeAddressComponent(AddressComponent $addressComponent)
593
    {
594
        unset($this->addressComponents[array_search($addressComponent, $this->addressComponents, true)]);
595
        $this->addressComponents = array_values($this->addressComponents);
596
    }
597
598
    /**
599
     * @return bool
600
     */
601
    public function hasPhotos()
602
    {
603
        return !empty($this->photos);
604
    }
605
606
    /**
607
     * @return Photo[]
608
     */
609
    public function getPhotos()
610
    {
611
        return $this->photos;
612
    }
613
614
    /**
615
     * @param Photo[] $photos
616
     */
617
    public function setPhotos(array $photos)
618
    {
619
        $this->photos = [];
620
        $this->addPhotos($photos);
621
    }
622
623
    /**
624
     * @param Photo[] $photos
625
     */
626
    public function addPhotos(array $photos)
627
    {
628
        foreach ($photos as $photo) {
629
            $this->addPhoto($photo);
630
        }
631
    }
632
633
    /**
634
     * @param Photo $photo
635
     *
636
     * @return bool
637
     */
638
    public function hasPhoto(Photo $photo)
639
    {
640
        return in_array($photo, $this->photos, true);
641
    }
642
643
    /**
644
     * @param Photo $photo
645
     */
646
    public function addPhoto(Photo $photo)
647
    {
648
        if (!$this->hasPhoto($photo)) {
649
            $this->photos[] = $photo;
650
        }
651
    }
652
653
    /**
654
     * @param Photo $photo
655
     */
656
    public function removePhoto(Photo $photo)
657
    {
658
        unset($this->photos[array_search($photo, $this->photos, true)]);
659
        $this->photos = array_values($this->photos);
660
    }
661
662
    /**
663
     * @return bool
664
     */
665
    public function hasAlternatePlaceIds()
666
    {
667
        return !empty($this->alternatePlaceIds);
668
    }
669
670
    /**
671
     * @return AlternatePlaceId[]
672
     */
673
    public function getAlternatePlaceIds()
674
    {
675
        return $this->alternatePlaceIds;
676
    }
677
678
    /**
679
     * @param AlternatePlaceId[] $alternatePlaceIds
680
     */
681
    public function setAlternatePlaceIds(array $alternatePlaceIds)
682
    {
683
        $this->alternatePlaceIds = [];
684
        $this->addAlternatePlaceIds($alternatePlaceIds);
685
    }
686
687
    /**
688
     * @param AlternatePlaceId[] $alternatePlaceIds
689
     */
690
    public function addAlternatePlaceIds(array $alternatePlaceIds)
691
    {
692
        foreach ($alternatePlaceIds as $alternatePlaceId) {
693
            $this->addAlternatePlaceId($alternatePlaceId);
694
        }
695
    }
696
697
    /**
698
     * @param AlternatePlaceId $alternatePlaceId
699
     *
700
     * @return bool
701
     */
702
    public function hasAlternatePlaceId(AlternatePlaceId $alternatePlaceId)
703
    {
704
        return in_array($alternatePlaceId, $this->alternatePlaceIds, true);
705
    }
706
707
    public function addAlternatePlaceId(AlternatePlaceId $alternatePlaceId)
708
    {
709
        if (!$this->hasAlternatePlaceId($alternatePlaceId)) {
710
            $this->alternatePlaceIds[] = $alternatePlaceId;
711
        }
712
    }
713
714
    /**
715
     * @param AlternatePlaceId $alternatePlaceId
716
     */
717
    public function removeAlternatePlaceId(AlternatePlaceId $alternatePlaceId)
718
    {
719
        unset($this->alternatePlaceIds[array_search($alternatePlaceId, $this->alternatePlaceIds, true)]);
720
        $this->alternatePlaceIds = array_values($this->alternatePlaceIds);
721
    }
722
723
    /**
724
     * @return bool
725
     */
726
    public function hasReviews()
727
    {
728
        return !empty($this->reviews);
729
    }
730
731
    /**
732
     * @return Review[]
733
     */
734
    public function getReviews()
735
    {
736
        return $this->reviews;
737
    }
738
739
    /**
740
     * @param Review[] $reviews
741
     */
742
    public function setReviews(array $reviews)
743
    {
744
        $this->reviews = [];
745
        $this->addReviews($reviews);
746
    }
747
748
    /**
749
     * @param Review[] $reviews
750
     */
751
    public function addReviews(array $reviews)
752
    {
753
        foreach ($reviews as $review) {
754
            $this->addReview($review);
755
        }
756
    }
757
758
    /**
759
     * @param Review $review
760
     *
761
     * @return bool
762
     */
763
    public function hasReview(Review $review)
764
    {
765
        return in_array($review, $this->reviews, true);
766
    }
767
768
    /**
769
     * @param Review $review
770
     */
771
    public function addReview(Review $review)
772
    {
773
        if (!$this->hasReview($review)) {
774
            $this->reviews[] = $review;
775
        }
776
    }
777
778
    /**
779
     * @param Review $review
780
     */
781
    public function removeReview(Review $review)
782
    {
783
        unset($this->reviews[array_search($review, $this->reviews, true)]);
784
        $this->reviews = array_values($this->reviews);
785
    }
786
787
    /**
788
     * @return bool
789
     */
790
    public function hasTypes()
791
    {
792
        return !empty($this->types);
793
    }
794
795
    /**
796
     * @return string[]
797
     */
798
    public function getTypes()
799
    {
800
        return $this->types;
801
    }
802
803
    /**
804
     * @param string[] $types
805
     */
806
    public function setTypes(array $types)
807
    {
808
        $this->types = [];
809
        $this->addTypes($types);
810
    }
811
812
    /**
813
     * @param string[] $types
814
     */
815
    public function addTypes(array $types)
816
    {
817
        foreach ($types as $type) {
818
            $this->addType($type);
819
        }
820
    }
821
822
    /**
823
     * @param string $type
824
     *
825
     * @return bool
826
     */
827
    public function hasType($type)
828
    {
829
        return in_array($type, $this->types, true);
830
    }
831
832
    /**
833
     * @param string $type
834
     */
835
    public function addType($type)
836
    {
837
        if (!$this->hasType($type)) {
838
            $this->types[] = $type;
839
        }
840
    }
841
842
    /**
843
     * @param string $type
844
     */
845
    public function removeType($type)
846
    {
847
        unset($this->types[array_search($type, $this->types, true)]);
848
        $this->types = array_values($this->types);
849
    }
850
851
    /**
852
     * @return bool
853
     */
854
    public function hasPermanentlyClose()
855
    {
856
        return $this->permanentlyClose !== null;
857
    }
858
859
    /**
860
     * @return bool|null
861
     */
862
    public function isPermanentlyClose()
863
    {
864
        return $this->permanentlyClose;
865
    }
866
867
    /**
868
     * @param bool|null $permanentlyClose
869
     */
870
    public function setPermanentlyClose($permanentlyClose)
871
    {
872
        $this->permanentlyClose = $permanentlyClose;
873
    }
874
}
875