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.

Place::setOpeningHours()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
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 $this->id !== null;
138
    }
139
140
    /**
141
     * @return string|null
142
     */
143 172
    public function getId()
144
    {
145 172
        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 $this->placeId !== null;
162
    }
163
164
    /**
165
     * @return string|null
166
     */
167 172
    public function getPlaceId()
168
    {
169 172
        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 $this->name !== null;
186
    }
187
188
    /**
189
     * @return string|null
190
     */
191 172
    public function getName()
192
    {
193 172
        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 $this->formattedAddress !== null;
210
    }
211
212
    /**
213
     * @return string|null
214
     */
215 172
    public function getFormattedAddress()
216
    {
217 172
        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 $this->formattedPhoneNumber !== null;
234
    }
235
236
    /**
237
     * @return string|null
238
     */
239 172
    public function getFormattedPhoneNumber()
240
    {
241 172
        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 $this->internationalPhoneNumber !== null;
258
    }
259
260
    /**
261
     * @return string|null
262
     */
263 172
    public function getInternationalPhoneNumber()
264
    {
265 172
        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 $this->url !== null;
282
    }
283
284
    /**
285
     * @return string|null
286
     */
287 172
    public function getUrl()
288
    {
289 172
        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 $this->icon !== null;
306
    }
307
308
    /**
309
     * @return string|null
310
     */
311 172
    public function getIcon()
312
    {
313 172
        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 $this->scope !== null;
330
    }
331
332
    /**
333
     * @return string|null
334
     */
335 172
    public function getScope()
336
    {
337 172
        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 $this->priceLevel !== null;
354
    }
355
356
    /**
357
     * @return int|null
358
     */
359 172
    public function getPriceLevel()
360
    {
361 172
        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 $this->rating !== null;
378
    }
379
380
    /**
381
     * @return float|null
382
     */
383 172
    public function getRating()
384
    {
385 172
        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 $this->utcOffset !== null;
402
    }
403
404
    /**
405
     * @return int|null
406
     */
407 172
    public function getUtcOffset()
408
    {
409 172
        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 $this->vicinity !== null;
426
    }
427
428
    /**
429
     * @return string|null
430
     */
431 172
    public function getVicinity()
432
    {
433 172
        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 $this->website !== null;
450
    }
451
452
    /**
453
     * @return string|null
454
     */
455 172
    public function getWebsite()
456
    {
457 172
        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 $this->geometry !== null;
474
    }
475
476
    /**
477
     * @return Geometry|null
478
     */
479 172
    public function getGeometry()
480
    {
481 172
        return $this->geometry;
482
    }
483
484
    /**
485
     * @param Geometry|null $geometry
486
     */
487 4
    public function setGeometry(Geometry $geometry = null)
488
    {
489 4
        $this->geometry = $geometry;
490 4
    }
491
492
    /**
493
     * @return bool
494
     */
495 8
    public function hasOpeningHours()
496
    {
497 8
        return $this->openingHours !== null;
498
    }
499
500
    /**
501
     * @return OpeningHours|null
502
     */
503 172
    public function getOpeningHours()
504
    {
505 172
        return $this->openingHours;
506
    }
507
508
    /**
509
     * @param OpeningHours|null $openingHours
510
     */
511 4
    public function setOpeningHours(OpeningHours $openingHours = null)
512
    {
513 4
        $this->openingHours = $openingHours;
514 4
    }
515
516
    /**
517
     * @param string|null $type
518
     *
519
     * @return bool
520
     */
521 24
    public function hasAddressComponents($type = null)
522
    {
523 24
        $addresses = $this->getAddressComponents($type);
524
525 24
        return !empty($addresses);
526
    }
527
528
    /**
529
     * @param string|null $type
530
     *
531
     * @return AddressComponent[]
532
     */
533 188 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 188
        if ($type === null) {
536 184
            return $this->addressComponents;
537
        }
538
539 4
        $addressComponents = [];
540
541 4
        foreach ($this->addressComponents as $addressComponent) {
542 4
            if (in_array($type, $addressComponent->getTypes(), true)) {
543 4
                $addressComponents[] = $addressComponent;
544 2
            }
545 2
        }
546
547 4
        return $addressComponents;
548
    }
549
550
    /**
551
     * @param AddressComponent[] $addressComponents
552
     */
553 12
    public function setAddressComponents(array $addressComponents)
554
    {
555 12
        $this->addressComponents = [];
556 12
        $this->addAddressComponents($addressComponents);
557 12
    }
558
559
    /**
560
     * @param AddressComponent[] $addressComponents
561
     */
562 12
    public function addAddressComponents(array $addressComponents)
563
    {
564 12
        foreach ($addressComponents as $addressComponent) {
565 12
            $this->addAddressComponent($addressComponent);
566 6
        }
567 12
    }
568
569
    /**
570
     * @param AddressComponent $addressComponent
571
     *
572
     * @return bool
573
     */
574 20
    public function hasAddressComponent(AddressComponent $addressComponent)
575
    {
576 20
        return in_array($addressComponent, $this->addressComponents, true);
577
    }
578
579
    /**
580
     * @param AddressComponent $addressComponent
581
     */
582 20
    public function addAddressComponent(AddressComponent $addressComponent)
583
    {
584 20
        if (!$this->hasAddressComponent($addressComponent)) {
585 20
            $this->addressComponents[] = $addressComponent;
586 10
        }
587 20
    }
588
589
    /**
590
     * @param AddressComponent $addressComponent
591
     */
592 4
    public function removeAddressComponent(AddressComponent $addressComponent)
593
    {
594 4
        unset($this->addressComponents[array_search($addressComponent, $this->addressComponents, true)]);
595 4
        $this->addressComponents = empty($this->addressComponents) ? [] : array_values($this->addressComponents);
596 4
    }
597
598
    /**
599
     * @return bool
600
     */
601 20
    public function hasPhotos()
602
    {
603 20
        return !empty($this->photos);
604
    }
605
606
    /**
607
     * @return Photo[]
608
     */
609 184
    public function getPhotos()
610
    {
611 184
        return $this->photos;
612
    }
613
614
    /**
615
     * @param Photo[] $photos
616
     */
617 8
    public function setPhotos(array $photos)
618
    {
619 8
        $this->photos = [];
620 8
        $this->addPhotos($photos);
621 8
    }
622
623
    /**
624
     * @param Photo[] $photos
625
     */
626 8
    public function addPhotos(array $photos)
627
    {
628 8
        foreach ($photos as $photo) {
629 8
            $this->addPhoto($photo);
630 4
        }
631 8
    }
632
633
    /**
634
     * @param Photo $photo
635
     *
636
     * @return bool
637
     */
638 16
    public function hasPhoto(Photo $photo)
639
    {
640 16
        return in_array($photo, $this->photos, true);
641
    }
642
643
    /**
644
     * @param Photo $photo
645
     */
646 16
    public function addPhoto(Photo $photo)
647
    {
648 16
        if (!$this->hasPhoto($photo)) {
649 16
            $this->photos[] = $photo;
650 8
        }
651 16
    }
652
653
    /**
654
     * @param Photo $photo
655
     */
656 4
    public function removePhoto(Photo $photo)
657
    {
658 4
        unset($this->photos[array_search($photo, $this->photos, true)]);
659 4
        $this->photos = empty($this->photos) ? [] : array_values($this->photos);
660 4
    }
661
662
    /**
663
     * @return bool
664
     */
665 20
    public function hasAlternatePlaceIds()
666
    {
667 20
        return !empty($this->alternatePlaceIds);
668
    }
669
670
    /**
671
     * @return AlternatePlaceId[]
672
     */
673 184
    public function getAlternatePlaceIds()
674
    {
675 184
        return $this->alternatePlaceIds;
676
    }
677
678
    /**
679
     * @param AlternatePlaceId[] $alternatePlaceIds
680
     */
681 8
    public function setAlternatePlaceIds(array $alternatePlaceIds)
682
    {
683 8
        $this->alternatePlaceIds = [];
684 8
        $this->addAlternatePlaceIds($alternatePlaceIds);
685 8
    }
686
687
    /**
688
     * @param AlternatePlaceId[] $alternatePlaceIds
689
     */
690 8
    public function addAlternatePlaceIds(array $alternatePlaceIds)
691
    {
692 8
        foreach ($alternatePlaceIds as $alternatePlaceId) {
693 8
            $this->addAlternatePlaceId($alternatePlaceId);
694 4
        }
695 8
    }
696
697
    /**
698
     * @param AlternatePlaceId $alternatePlaceId
699
     *
700
     * @return bool
701
     */
702 16
    public function hasAlternatePlaceId(AlternatePlaceId $alternatePlaceId)
703
    {
704 16
        return in_array($alternatePlaceId, $this->alternatePlaceIds, true);
705
    }
706
707 16
    public function addAlternatePlaceId(AlternatePlaceId $alternatePlaceId)
708
    {
709 16
        if (!$this->hasAlternatePlaceId($alternatePlaceId)) {
710 16
            $this->alternatePlaceIds[] = $alternatePlaceId;
711 8
        }
712 16
    }
713
714
    /**
715
     * @param AlternatePlaceId $alternatePlaceId
716
     */
717 4
    public function removeAlternatePlaceId(AlternatePlaceId $alternatePlaceId)
718
    {
719 4
        unset($this->alternatePlaceIds[array_search($alternatePlaceId, $this->alternatePlaceIds, true)]);
720 4
        $this->alternatePlaceIds = empty($this->alternatePlaceIds) ? [] : array_values($this->alternatePlaceIds);
721 4
    }
722
723
    /**
724
     * @return bool
725
     */
726 20
    public function hasReviews()
727
    {
728 20
        return !empty($this->reviews);
729
    }
730
731
    /**
732
     * @return Review[]
733
     */
734 184
    public function getReviews()
735
    {
736 184
        return $this->reviews;
737
    }
738
739
    /**
740
     * @param Review[] $reviews
741
     */
742 8
    public function setReviews(array $reviews)
743
    {
744 8
        $this->reviews = [];
745 8
        $this->addReviews($reviews);
746 8
    }
747
748
    /**
749
     * @param Review[] $reviews
750
     */
751 8
    public function addReviews(array $reviews)
752
    {
753 8
        foreach ($reviews as $review) {
754 8
            $this->addReview($review);
755 4
        }
756 8
    }
757
758
    /**
759
     * @param Review $review
760
     *
761
     * @return bool
762
     */
763 16
    public function hasReview(Review $review)
764
    {
765 16
        return in_array($review, $this->reviews, true);
766
    }
767
768
    /**
769
     * @param Review $review
770
     */
771 16
    public function addReview(Review $review)
772
    {
773 16
        if (!$this->hasReview($review)) {
774 16
            $this->reviews[] = $review;
775 8
        }
776 16
    }
777
778
    /**
779
     * @param Review $review
780
     */
781 4
    public function removeReview(Review $review)
782
    {
783 4
        unset($this->reviews[array_search($review, $this->reviews, true)]);
784 4
        $this->reviews = empty($this->reviews) ? [] : array_values($this->reviews);
785 4
    }
786
787
    /**
788
     * @return bool
789
     */
790 20
    public function hasTypes()
791
    {
792 20
        return !empty($this->types);
793
    }
794
795
    /**
796
     * @return string[]
797
     */
798 184
    public function getTypes()
799
    {
800 184
        return $this->types;
801
    }
802
803
    /**
804
     * @param string[] $types
805
     */
806 8
    public function setTypes(array $types)
807
    {
808 8
        $this->types = [];
809 8
        $this->addTypes($types);
810 8
    }
811
812
    /**
813
     * @param string[] $types
814
     */
815 8
    public function addTypes(array $types)
816
    {
817 8
        foreach ($types as $type) {
818 8
            $this->addType($type);
819 4
        }
820 8
    }
821
822
    /**
823
     * @param string $type
824
     *
825
     * @return bool
826
     */
827 16
    public function hasType($type)
828
    {
829 16
        return in_array($type, $this->types, true);
830
    }
831
832
    /**
833
     * @param string $type
834
     */
835 16
    public function addType($type)
836
    {
837 16
        if (!$this->hasType($type)) {
838 16
            $this->types[] = $type;
839 8
        }
840 16
    }
841
842
    /**
843
     * @param string $type
844
     */
845 4
    public function removeType($type)
846
    {
847 4
        unset($this->types[array_search($type, $this->types, true)]);
848 4
        $this->types = empty($this->types) ? [] : array_values($this->types);
849 4
    }
850
851
    /**
852
     * @return bool
853
     */
854 8
    public function hasPermanentlyClose()
855
    {
856 8
        return $this->permanentlyClose !== null;
857
    }
858
859
    /**
860
     * @return bool|null
861
     */
862 172
    public function isPermanentlyClose()
863
    {
864 172
        return $this->permanentlyClose;
865
    }
866
867
    /**
868
     * @param bool|null $permanentlyClose
869
     */
870 4
    public function setPermanentlyClose($permanentlyClose)
871
    {
872 4
        $this->permanentlyClose = $permanentlyClose;
873 4
    }
874
}
875