Completed
Push — master ( baf9da...f0bca5 )
by Bradley
03:12
created

MapperBase::disableLocate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
cc 1
eloc 2
nc 1
nop 0
rs 10
1
<?php namespace Cornford\Googlmapper;
2
3
use Cornford\Googlmapper\Contracts\MappingBaseInterface;
4
use Cornford\Googlmapper\Exceptions\MapperArgumentException;
5
use Illuminate\View\Factory as View;
6
7
abstract class MapperBase implements MappingBaseInterface
8
{
9
10
	const ENABLED = true;
11
12
	const REGION = 'GB';
13
14
	const LANGUAGE = 'en-gb';
15
16
	const TYPE_ROADMAP = 'ROADMAP';
17
	const TYPE_SATELLITE = 'SATELLITE';
18
	const TYPE_HYBRID = 'HYBRID';
19
	const TYPE_TERRAIN = 'TERRAIN';
20
21
	const USER = false;
22
23
	const MARKER = true;
24
25
	const CENTER = true;
26
27
	const LOCATE = false;
28
29
	const ZOOM = 8;
30
	const SCROLL_WHEEL_ZOOM = true;
31
32
	const TILT = 90;
33
34
	const UI = true;
35
36
	const ANIMATION_NONE = 'NONE';
37
	const ANIMATION_DROP = 'DROP';
38
	const ANIMATION_BOUNCE = 'BOUNCE';
39
40
	const OVERLAY_NONE = 'NONE';
41
	const OVERLAY_BIKE = 'BIKE';
42
	const OVERLAY_TRANSIT = 'TRANSIT';
43
	const OVERLAY_TRAFFIC = 'TRAFFIC';
44
45
	const SYMBOL_CIRCLE = 'CIRCLE';
46
	const SYMBOL_BACKWARD_CLOSED_ARROW = 'BACKWARD_CLOSED_ARROW';
47
	const SYMBOL_FORWARD_CLOSED_ARROW = 'FORWARD_CLOSED_ARROW';
48
	const SYMBOL_BACKWARD_OPEN_ARROW = 'BACKWARD_OPEN_ARROW';
49
	const SYMBOL_FORWARD_OPEN_ARROW = 'FORWARD_OPEN_ARROW';
50
51
	const ICON = '';
52
53
	const CLUSTER = true;
54
55
	const CLUSTERS_ICON = '//googlemaps.github.io/js-marker-clusterer/images/m';
56
	const CLUSTERS_GRID = 60;
57
	const CLUSTERS_ZOOM = null;
58
	const CLUSTERS_CENTER = false;
59
	const CLUSTERS_SIZE = 2;
60
61
	/**
62
	 * View.
63
	 *
64
	 * @var \Illuminate\View\Factory
65
	 */
66
	protected $view;
67
68
	/**
69
	 * Mapping enabled.
70
	 *
71
	 * @var boolean
72
	 */
73
	protected $enabled;
74
75
	/**
76
	 * API Key.
77
	 *
78
	 * @var string
79
	 */
80
	protected $key;
81
82
	/**
83
	 * API Version.
84
	 *
85
	 * @var integer
86
	 */
87
	protected $version = '3.exp';
88
89
	/**
90
	 * API region.
91
	 *
92
	 * @var string
93
	 */
94
	protected $region;
95
96
	/**
97
	 * API regions.
98
	 *
99
	 * @var array
100
	 */
101
	protected $regions = [
102
		'AF',
103
		'AX',
104
		'AL',
105
		'DZ',
106
		'AS',
107
		'AD',
108
		'AO',
109
		'AI',
110
		'AQ',
111
		'AG',
112
		'AR',
113
		'AM',
114
		'AW',
115
		'AU',
116
		'AT',
117
		'AZ',
118
		'BS',
119
		'BH',
120
		'BD',
121
		'BB',
122
		'BY',
123
		'BE',
124
		'BZ',
125
		'BJ',
126
		'BM',
127
		'BT',
128
		'BO',
129
		'BQ',
130
		'BA',
131
		'BW',
132
		'BV',
133
		'BR',
134
		'IO',
135
		'BN',
136
		'BG',
137
		'BF',
138
		'BI',
139
		'KH',
140
		'CM',
141
		'CA',
142
		'CV',
143
		'KY',
144
		'CF',
145
		'TD',
146
		'CL',
147
		'CN',
148
		'CX',
149
		'CC',
150
		'CO',
151
		'KM',
152
		'CG',
153
		'CD',
154
		'CK',
155
		'CR',
156
		'CI',
157
		'HR',
158
		'CU',
159
		'CW',
160
		'CY',
161
		'CZ',
162
		'DK',
163
		'DJ',
164
		'DM',
165
		'DO',
166
		'EC',
167
		'EG',
168
		'SV',
169
		'GQ',
170
		'ER',
171
		'EE',
172
		'ET',
173
		'FK',
174
		'FO',
175
		'FJ',
176
		'FI',
177
		'FR',
178
		'GF',
179
		'PF',
180
		'TF',
181
		'GA',
182
		'GM',
183
		'GE',
184
		'DE',
185
		'GH',
186
		'GI',
187
		'GR',
188
		'GL',
189
		'GD',
190
		'GP',
191
		'GU',
192
		'GT',
193
		'GG',
194
		'GN',
195
		'GW',
196
		'GY',
197
		'HT',
198
		'HM',
199
		'VA',
200
		'HN',
201
		'HK',
202
		'HU',
203
		'IS',
204
		'IN',
205
		'ID',
206
		'IR',
207
		'IQ',
208
		'IE',
209
		'IM',
210
		'IL',
211
		'IT',
212
		'JM',
213
		'JP',
214
		'JE',
215
		'JO',
216
		'KZ',
217
		'KE',
218
		'KI',
219
		'KP',
220
		'KR',
221
		'KW',
222
		'KG',
223
		'LA',
224
		'LV',
225
		'LB',
226
		'LS',
227
		'LR',
228
		'LY',
229
		'LI',
230
		'LT',
231
		'LU',
232
		'MO',
233
		'MK',
234
		'MG',
235
		'MW',
236
		'MY',
237
		'MV',
238
		'ML',
239
		'MT',
240
		'MH',
241
		'MQ',
242
		'MR',
243
		'MU',
244
		'YT',
245
		'MX',
246
		'FM',
247
		'MD',
248
		'MC',
249
		'MN',
250
		'ME',
251
		'MS',
252
		'MA',
253
		'MZ',
254
		'MM',
255
		'NA',
256
		'NR',
257
		'NP',
258
		'NL',
259
		'NC',
260
		'NZ',
261
		'NI',
262
		'NE',
263
		'NG',
264
		'NU',
265
		'NF',
266
		'MP',
267
		'NO',
268
		'OM',
269
		'PK',
270
		'PW',
271
		'PS',
272
		'PA',
273
		'PG',
274
		'PY',
275
		'PE',
276
		'PH',
277
		'PN',
278
		'PL',
279
		'PT',
280
		'PR',
281
		'QA',
282
		'RE',
283
		'RO',
284
		'RU',
285
		'RW',
286
		'BL',
287
		'SH',
288
		'KN',
289
		'LC',
290
		'MF',
291
		'PM',
292
		'VC',
293
		'WS',
294
		'SM',
295
		'ST',
296
		'SA',
297
		'SN',
298
		'RS',
299
		'SC',
300
		'SL',
301
		'SG',
302
		'SX',
303
		'SK',
304
		'SI',
305
		'SB',
306
		'SO',
307
		'ZA',
308
		'GS',
309
		'SS',
310
		'ES',
311
		'LK',
312
		'SD',
313
		'SR',
314
		'SJ',
315
		'SZ',
316
		'SE',
317
		'CH',
318
		'SY',
319
		'TW',
320
		'TJ',
321
		'TZ',
322
		'TH',
323
		'TL',
324
		'TG',
325
		'TK',
326
		'TO',
327
		'TT',
328
		'TN',
329
		'TR',
330
		'TM',
331
		'TC',
332
		'TV',
333
		'UG',
334
		'UA',
335
		'AE',
336
		'GB',
337
		'US',
338
		'UM',
339
		'UY',
340
		'UZ',
341
		'VU',
342
		'VE',
343
		'VN',
344
		'VG',
345
		'VI',
346
		'WF',
347
		'EH',
348
		'YE',
349
		'ZM',
350
		'ZW'
351
	];
352
353
	/**
354
	 * API Language.
355
	 *
356
	 * @var string
357
	 */
358
	protected $language;
359
360
	/**
361
	 * API Languages.
362
	 *
363
	 * @var array
364
	 */
365
	protected $languages = [
366
		'af',
367
		'ar-ae',
368
		'ar-bh',
369
		'ar-dz',
370
		'ar-eg',
371
		'ar-iq',
372
		'ar-jo',
373
		'ar-kw',
374
		'ar-lb',
375
		'ar-ly',
376
		'ar-ma',
377
		'ar-om',
378
		'ar-qa',
379
		'ar-sa',
380
		'ar-sy',
381
		'ar-tn',
382
		'ar-ye',
383
		'be',
384
		'bg',
385
		'ca',
386
		'cs',
387
		'da',
388
		'de',
389
		'de-at',
390
		'de-ch',
391
		'de-li',
392
		'de-lu',
393
		'el',
394
		'en',
395
		'en-au',
396
		'en-bz',
397
		'en-ca',
398
		'en-gb',
399
		'en-ie',
400
		'en-jm',
401
		'en-nz',
402
		'en-tt',
403
		'en-us',
404
		'en-za',
405
		'es',
406
		'es-ar',
407
		'es-bo',
408
		'es-cl',
409
		'es-co',
410
		'es-cr',
411
		'es-do',
412
		'es-ec',
413
		'es-gt',
414
		'es-hn',
415
		'es-mx',
416
		'es-ni',
417
		'es-pa',
418
		'es-pe',
419
		'es-pr',
420
		'es-py',
421
		'es-sv',
422
		'es-uy',
423
		'es-ve',
424
		'et',
425
		'eu',
426
		'fa',
427
		'fi',
428
		'fo',
429
		'fr',
430
		'fr-be',
431
		'fr-ca',
432
		'fr-ch',
433
		'fr-lu',
434
		'ga',
435
		'gd',
436
		'he',
437
		'hi',
438
		'hr',
439
		'hu',
440
		'id',
441
		'is',
442
		'it',
443
		'it-ch',
444
		'ja',
445
		'ji',
446
		'ko',
447
		'ko',
448
		'ku',
449
		'lt',
450
		'lv',
451
		'mk',
452
		'ml',
453
		'ms',
454
		'mt',
455
		'nl',
456
		'nl-be',
457
		'nb',
458
		'nn',
459
		'no',
460
		'pa',
461
		'pl',
462
		'pt',
463
		'pt-br',
464
		'rm',
465
		'ro',
466
		'ro-md',
467
		'ru',
468
		'ru-md',
469
		'sb',
470
		'sk',
471
		'sl',
472
		'sq',
473
		'sr',
474
		'sv',
475
		'sv-fi',
476
		'th',
477
		'tn',
478
		'tr',
479
		'ts',
480
		'uk',
481
		'ur',
482
		've',
483
		'vi',
484
		'xh',
485
		'zh-cn',
486
		'zh-hk',
487
		'zh-sg',
488
		'zh-tw',
489
		'zu'
490
	];
491
492
	/**
493
	 * User custom maps.
494
	 *
495
	 * @var boolean
496
	 */
497
	protected $user;
498
499
	/**
500
	 * Automatic map marker.
501
	 *
502
	 * @var boolean
503
	 */
504
	protected $marker;
505
506
	/**
507
	 * Center map automatically.
508
	 *
509
	 * @var boolean
510
	 */
511
	protected $center;
512
513
	/**
514
	 * Locate users location.
515
	 *
516
	 * @var boolean
517
	 */
518
	protected $locate;
519
520
	/**
521
	 * Show map UI.
522
	 *
523
	 * @var boolean
524
	 */
525
	protected $ui;
526
527
	/**
528
	 * Map zoom level.
529
	 *
530
	 * @var integer
531
	 */
532
	protected $zoom;
533
534
	/**
535
	 * Map scroll wheel zoom.
536
	 *
537
	 * @var boolean
538
	 */
539
	protected $scrollWheelZoom;
540
541
	/**
542
	 * Map type.
543
	 *
544
	 * @var string
545
	 */
546
	protected $type;
547
548
	/**
549
	 * Available map types.
550
	 *
551
	 * @var array
552
	 */
553
	protected $types = [
554
		'ROADMAP',
555
		'SATELLITE',
556
		'HYBRID',
557
		'TERRAIN'
558
	];
559
560
	/**
561
	 * Map tilt.
562
	 *
563
	 * @var integer
564
	 */
565
	protected $tilt;
566
567
	/**
568
	 * Map marker icon.
569
	 *
570
	 * @var string
571
	 */
572
	protected $icon;
573
574
	/**
575
	 * Map marker animation.
576
	 *
577
	 * @var string
578
	 */
579
	protected $animation;
580
581
	/**
582
	 * Available map marker animations.
583
	 *
584
	 * @var array
585
	 */
586
	protected $animations = [
587
		'NONE',
588
		'DROP',
589
		'BOUNCE',
590
	];
591
592
	/**
593
	 * Map marker cluster.
594
	 *
595
	 * @var boolean
596
	 */
597
	protected $cluster;
598
599
	/**
600
	 * Map marker clusters icon.
601
	 *
602
	 * @var array
603
	 */
604
	protected $clustersIcon;
605
606
	/**
607
	 * Map marker clusters grid.
608
	 *
609
	 * @var integer
610
	 */
611
	protected $clustersGrid;
612
613
	/**
614
	 * Map marker clusters zoom.
615
	 *
616
	 * @var integer|null
617
	 */
618
	protected $clustersZoom;
619
620
	/**
621
	 * Map marker clusters center.
622
	 *
623
	 * @var boolean
624
	 */
625
	protected $clustersCenter;
626
627
	/**
628
	 * Map marker clusters size.
629
	 *
630
	 * @var integer
631
	 */
632
	protected $clustersSize;
633
634
	/**
635
	 * Mapping items.
636
	 *
637
	 * @var array
638
	 */
639
	public $items = [];
640
641
	/**
642
	 * Construct Googlmapper.
643
	 *
644
	 * @param View  $view
645
	 * @param array $options
646
	 *
647
	 * @throws MapperArgumentException
648
	 */
649
	public function __construct(View $view, array $options = [])
650
	{
651
		$this->view = $view;
652
653
		if (!isset($options['key'])) {
654
			throw new MapperArgumentException('Google maps API key is required.');
655
		}
656
657
		if (!isset($options['region'])) {
658
			throw new MapperArgumentException('Region is required.');
659
		}
660
661
		if (!in_array($options['region'], $this->regions)) {
662
			throw new MapperArgumentException('Region is required in ISO 3166-1 code format.');
663
		}
664
665
		if (!isset($options['language']) || !in_array($options['language'], $this->languages)) {
666
			throw new MapperArgumentException('Language is required.');
667
		}
668
669
		if (!in_array($options['language'], $this->languages)) {
670
			throw new MapperArgumentException('Language is required in ISO 639-1 code format.');
671
		}
672
673
		$this->setEnabled(isset($options['enabled']) ? $options['enabled'] : self::ENABLED);
674
		$this->setKey($options['key']);
675
		$this->setRegion(isset($options['region']) ? $options['region'] : self::REGION);
676
		$this->setLanguage(isset($options['language']) ? $options['language'] : self::LANGUAGE);
677
		$this->setUser(isset($options['user']) ? $options['user'] : self::USER);
678
		$this->setMarker(isset($options['marker']) ? $options['marker'] : self::MARKER);
679
		$this->setCenter(isset($options['center']) ? $options['center'] : self::CENTER);
680
		$this->setLocate(isset($options['locate']) ? $options['locate'] : self::LOCATE);
681
		$this->setZoom(isset($options['zoom']) ? $options['zoom'] : self::ZOOM);
682
		$this->setScrollWheelZoom(isset($options['scrollWheelZoom']) ? $options['scrollWheelZoom'] : self::SCROLL_WHEEL_ZOOM);
683
		$this->setType(isset($options['type']) ? $options['type'] : self::TYPE_ROADMAP);
684
		$this->setTilt(isset($options['tilt']) ? $options['tilt'] : self::TILT);
685
		$this->setUi(isset($options['ui']) ? $options['ui'] : self::UI);
686
		$this->setIcon(isset($options['markers']['icon']) ? $options['markers']['icon'] : self::ICON);
687
		$this->setAnimation(isset($options['markers']['animation']) ? $options['markers']['animation'] : self::ANIMATION_NONE);
688
		$this->setCluster(isset($options['cluster']) ? $options['cluster'] : self::CLUSTER);
689
		$this->setClustersIcon(isset($options['clusters']['icon']) ? $options['clusters']['icon'] : self::CLUSTERS_ICON);
690
		$this->setClustersGrid(isset($options['clusters']['grid']) ? $options['clusters']['grid'] : self::CLUSTERS_GRID);
691
		$this->setClustersZoom(isset($options['clusters']['zoom']) ? $options['clusters']['zoom'] : self::CLUSTERS_ZOOM);
692
		$this->setClustersCenter(isset($options['clusters']['center']) ? $options['clusters']['center'] : self::CLUSTERS_CENTER);
693
		$this->setClustersSize(isset($options['clusters']['size']) ? $options['clusters']['size'] : self::CLUSTERS_SIZE);
694
	}
695
696
	/**
697
	 * Is mapping enabled?
698
	 *
699
	 * @return boolean
700
	 */
701
	public function isEnabled()
702
	{
703
		return $this->getEnabled();
704
	}
705
706
	/**
707
	 * Set enabled status.
708
	 *
709
	 * @param boolean $value
710
	 *
711
	 * @throws MapperArgumentException
712
	 *
713
	 * @return void
714
	 */
715
	protected function setEnabled($value)
716
	{
717
		if (!is_bool($value)) {
718
			throw new MapperArgumentException('Invalid map enabled setting.');
719
		}
720
721
		$this->enabled = $value;
722
	}
723
724
	/**
725
	 * Get the enabled status.
726
	 *
727
	 * @return boolean
728
	 */
729
	protected function getEnabled()
730
	{
731
		return $this->enabled;
732
	}
733
734
	/**
735
	 * Enable mapping.
736
	 *
737
	 * @return void
738
	 */
739
	public function enableMapping()
740
	{
741
		$this->setEnabled(true);
742
	}
743
744
	/**
745
	 * Disable mapping.
746
	 *
747
	 * @return void
748
	 */
749
	public function disableMapping()
750
	{
751
		$this->setEnabled(false);
752
	}
753
754
	/**
755
	 * Set the Google Maps key.
756
	 *
757
	 * @param string $value
758
	 *
759
	 * @throws MapperArgumentException
760
	 *
761
	 * @return void
762
	 */
763
	public function setKey($value)
764
	{
765
		if (!is_string($value)) {
766
			throw new MapperArgumentException('Invalid Google Map\'s API key.');
767
		}
768
769
		$this->key = $value;
770
	}
771
772
	/**
773
	 * Get the Google Maps key.
774
	 *
775
	 * @return string
776
	 */
777
	public function getKey()
778
	{
779
		return $this->key;
780
	}
781
782
	/**
783
	 * Set the Google Maps region.
784
	 *
785
	 * @param string $value
786
	 *
787
	 * @throws MapperArgumentException
788
	 *
789
	 * @return void
790
	 */
791 View Code Duplication
	public function setRegion($value)
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...
792
	{
793
		if (!is_string($value)) {
794
			throw new MapperArgumentException('Invalid map region.');
795
		}
796
797
		if (!in_array($value, $this->regions)) {
798
			throw new MapperArgumentException('Region is required in ISO 3166-1 code format.');
799
		}
800
801
		$this->region = $value;
802
	}
803
804
	/**
805
	 * Get the Google Maps region.
806
	 *
807
	 * @return string
808
	 */
809
	public function getRegion()
810
	{
811
		return $this->region;
812
	}
813
814
	/**
815
	 * Set the Google Maps language.
816
	 *
817
	 * @param string $value
818
	 *
819
	 * @throws MapperArgumentException
820
	 *
821
	 * @return void
822
	 */
823 View Code Duplication
	public function setLanguage($value)
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...
824
	{
825
		if (!is_string($value)) {
826
			throw new MapperArgumentException('Invalid map language.');
827
		}
828
829
		if (!in_array($value, $this->languages)) {
830
			throw new MapperArgumentException('Language is required in ISO 639-1 code format.');
831
		}
832
833
		$this->language = $value;
834
	}
835
836
	/**
837
	 * Get the Google Maps language.
838
	 *
839
	 * @return string
840
	 */
841
	public function getLanguage()
842
	{
843
		return $this->language;
844
	}
845
846
	/**
847
	 * Set the map user status.
848
	 *
849
	 * @param boolean $value
850
	 *
851
	 * @throws MapperArgumentException
852
	 *
853
	 * @return void
854
	 */
855
	protected function setUser($value)
856
	{
857
		if (!is_bool($value)) {
858
			throw new MapperArgumentException('Invalid map user status.');
859
		}
860
861
		$this->user = $value;
862
	}
863
864
	/**
865
	 * Get the map user status.
866
	 *
867
	 * @return boolean
868
	 */
869
	public function getUser()
870
	{
871
		return $this->user;
872
	}
873
874
	/**
875
	 * Enable users for maps.
876
	 *
877
	 * @return void
878
	 */
879
	public function enableUsers()
880
	{
881
		$this->setUser(true);
882
	}
883
884
	/**
885
	 * Disable users for maps.
886
	 *
887
	 * @return void
888
	 */
889
	public function disableUsers()
890
	{
891
		$this->setUser(false);
892
	}
893
894
	/**
895
	 * Set the marker status.
896
	 *
897
	 * @param boolean $value
898
	 *
899
	 * @throws MapperArgumentException
900
	 *
901
	 * @return void
902
	 */
903
	protected function setMarker($value)
904
	{
905
		if (!is_bool($value)) {
906
			throw new MapperArgumentException('Invalid map marker setting.');
907
		}
908
909
		$this->marker = $value;
910
	}
911
912
	/**
913
	 * Get the marker status.
914
	 *
915
	 * @return boolean
916
	 */
917
	public function getMarker()
918
	{
919
		return $this->marker;
920
	}
921
922
	/**
923
	 * Enable markers for maps.
924
	 *
925
	 * @return void
926
	 */
927
	public function enableMarkers()
928
	{
929
		$this->setMarker(true);
930
	}
931
932
	/**
933
	 * Disable markers for maps.
934
	 *
935
	 * @return void
936
	 */
937
	public function disableMarkers()
938
	{
939
		$this->setMarker(false);
940
	}
941
942
	/**
943
	 * Set the map center status.
944
	 *
945
	 * @param boolean $value
946
	 *
947
	 * @throws MapperArgumentException
948
	 *
949
	 * @return void
950
	 */
951
	protected function setCenter($value)
952
	{
953
		if (!is_bool($value)) {
954
			throw new MapperArgumentException('Invalid map center setting.');
955
		}
956
957
		$this->center = $value;
958
	}
959
960
	/**
961
	 * Get the map center status.
962
	 *
963
	 * @return boolean
964
	 */
965
	public function getCenter()
966
	{
967
		return $this->center;
968
	}
969
970
	/**
971
	 * Enable center of maps.
972
	 *
973
	 * @return void
974
	 */
975
	public function enableCenter()
976
	{
977
		$this->setCenter(true);
978
	}
979
980
	/**
981
	 * Disable center of maps.
982
	 *
983
	 * @return void
984
	 */
985
	public function disableCenter()
986
	{
987
		$this->setCenter(false);
988
	}
989
990
	/**
991
	 * Set the map locate user status.
992
	 *
993
	 * @param boolean $value
994
	 *
995
	 * @throws MapperArgumentException
996
	 *
997
	 * @return void
998
	 */
999
	protected function setLocate($value)
1000
	{
1001
		if (!is_bool($value)) {
1002
			throw new MapperArgumentException('Invalid map locate setting.');
1003
		}
1004
1005
		$this->locate = $value;
1006
	}
1007
1008
	/**
1009
	 * Get the map locate user status.
1010
	 *
1011
	 * @return boolean
1012
	 */
1013
	public function getLocate()
1014
	{
1015
		return $this->locate;
1016
	}
1017
1018
	/**
1019
	 * Enable locate user position on maps.
1020
	 *
1021
	 * @return void
1022
	 */
1023
	public function enableLocate()
1024
	{
1025
		$this->setLocate(true);
1026
	}
1027
1028
	/**
1029
	 * Disable locate user position on maps.
1030
	 *
1031
	 * @return void
1032
	 */
1033
	public function disableLocate()
1034
	{
1035
		$this->setLocate(false);
1036
	}
1037
1038
	/**
1039
	 * Set the map UI status.
1040
	 *
1041
	 * @param boolean $value
1042
	 *
1043
	 * @throws MapperArgumentException
1044
	 *
1045
	 * @return void
1046
	 */
1047
	protected function setUi($value)
1048
	{
1049
		if (!is_bool($value)) {
1050
			throw new MapperArgumentException('Invalid map ui setting.');
1051
		}
1052
1053
		$this->ui = $value;
1054
	}
1055
1056
	/**
1057
	 * Get the map UI status.
1058
	 *
1059
	 * @return boolean
1060
	 */
1061
	public function getUi()
1062
	{
1063
		return $this->ui;
1064
	}
1065
1066
	/**
1067
	 * Enable maps ui.
1068
	 *
1069
	 * @return void
1070
	 */
1071
	public function enableUi()
1072
	{
1073
		$this->setUi(false);
1074
	}
1075
1076
	/**
1077
	 * Disable maps ui.
1078
	 *
1079
	 * @return void
1080
	 */
1081
	public function disableUi()
1082
	{
1083
		$this->setUi(true);
1084
	}
1085
1086
	/**
1087
	 * Set map zoom level.
1088
	 *
1089
	 * @param integer $value
1090
	 *
1091
	 * @throws MapperArgumentException
1092
	 *
1093
	 * @return void
1094
	 */
1095
	public function setZoom($value)
1096
	{
1097
		if (!is_numeric($value)) {
1098
			throw new MapperArgumentException('Zoom level must be an integer.');
1099
		}
1100
1101
		if ($value < 1 || $value > 20) {
1102
			throw new MapperArgumentException('A zoom level must be between 1 and 20.');
1103
		}
1104
1105
		$this->zoom = $value;
0 ignored issues
show
Documentation Bug introduced by
It seems like $value can also be of type double or string. However, the property $zoom is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
1106
	}
1107
1108
	/**
1109
	 * Get map zoom level.
1110
	 *
1111
	 * @return integer
1112
	 */
1113
	public function getZoom()
1114
	{
1115
		return $this->zoom;
1116
	}
1117
1118
	/**
1119
	 * Set map scroll wheel zoom.
1120
	 *
1121
	 * @param boolean $value
1122
	 *
1123
	 * @throws MapperArgumentException
1124
	 *
1125
	 * @return void
1126
	 */
1127
	public function setScrollWheelZoom($value)
1128
	{
1129
		if (!is_bool($value)) {
1130
			throw new MapperArgumentException('Mouse Wheel Zoom must be a boolean.');
1131
		}
1132
1133
		$this->scrollWheelZoom = $value;
1134
	}
1135
1136
	/**
1137
	 * Get map scroll wheel zoom.
1138
	 *
1139
	 * @return boolean
1140
	 */
1141
	public function getScrollWheelZoom()
1142
	{
1143
		return $this->scrollWheelZoom;
1144
	}
1145
1146
	/**
1147
	 * Set map type.
1148
	 *
1149
	 * @param string $value
1150
	 *
1151
	 * @throws MapperArgumentException
1152
	 *
1153
	 * @return void
1154
	 */
1155
	public function setType($value)
1156
	{
1157
		if (!in_array($value, $this->types)) {
1158
			throw new MapperArgumentException('Invalid map type.');
1159
		}
1160
1161
		$this->type = $value;
1162
	}
1163
1164
	/**
1165
	 * Get map type.
1166
	 *
1167
	 * @return string
1168
	 */
1169
	public function getType()
1170
	{
1171
		return $this->type;
1172
	}
1173
1174
	/**
1175
	 * Set map tilt.
1176
	 *
1177
	 * @param integer|double $value
1178
	 *
1179
	 * @throws MapperArgumentException
1180
	 *
1181
	 * @return void
1182
	 */
1183
	public function setTilt($value)
1184
	{
1185
		if (!is_numeric($value)) {
1186
			throw new MapperArgumentException('Invalid map tilt.');
1187
		}
1188
1189
		$this->tilt = $value;
0 ignored issues
show
Documentation Bug introduced by
It seems like $value can also be of type double or string. However, the property $tilt is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
1190
	}
1191
1192
	/**
1193
	 * Get map $tilt.
1194
	 *
1195
	 * @return integer
1196
	 */
1197
	public function getTilt()
1198
	{
1199
		return $this->tilt;
1200
	}
1201
1202
	/**
1203
	 * Set map marker icon.
1204
	 *
1205
	 * @param string $value
1206
	 *
1207
	 * @throws MapperArgumentException
1208
	 *
1209
	 * @return void
1210
	 */
1211
	public function setIcon($value)
1212
	{
1213
		if (!is_string($value)) {
1214
			throw new MapperArgumentException('Invalid map marker icon.');
1215
		}
1216
1217
		$this->icon = $value;
1218
	}
1219
1220
	/**
1221
	 * Get map marker icon.
1222
	 *
1223
	 * @return string
1224
	 */
1225
	public function getIcon()
1226
	{
1227
		return $this->icon;
1228
	}
1229
1230
	/**
1231
	 * Set map marker animation.
1232
	 *
1233
	 * @param string $value
1234
	 *
1235
	 * @throws MapperArgumentException
1236
	 *
1237
	 * @return void
1238
	 */
1239
	public function setAnimation($value)
1240
	{
1241
		if (!in_array($value, $this->animations)) {
1242
			throw new MapperArgumentException('Invalid map marker animation.');
1243
		}
1244
1245
		$this->animation = $value;
1246
	}
1247
1248
	/**
1249
	 * Get map marker animation.
1250
	 *
1251
	 * @return string
1252
	 */
1253
	public function getAnimation()
1254
	{
1255
		return $this->animation;
1256
	}
1257
	/**
1258
	 * Set cluster status.
1259
	 *
1260
	 * @param boolean $value
1261
	 *
1262
	 * @throws MapperArgumentException
1263
	 *
1264
	 * @return void
1265
	 */
1266
	protected function setCluster($value)
1267
	{
1268
		if (!is_bool($value)) {
1269
			throw new MapperArgumentException('Invalid map cluster setting.');
1270
		}
1271
1272
		$this->cluster = $value;
1273
	}
1274
1275
	/**
1276
	 * Get the cluster status.
1277
	 *
1278
	 * @return boolean
1279
	 */
1280
	public function getCluster()
1281
	{
1282
		return $this->cluster;
1283
	}
1284
1285
	/**
1286
	 * Enable cluster.
1287
	 *
1288
	 * @return void
1289
	 */
1290
	public function enableCluster()
1291
	{
1292
		$this->setCluster(true);
1293
	}
1294
1295
	/**
1296
	 * Disable cluster.
1297
	 *
1298
	 * @return void
1299
	 */
1300
	public function disableCluster()
1301
	{
1302
		$this->setCluster(false);
1303
	}
1304
1305
	/**
1306
	 * Set map cluster icon.
1307
	 *
1308
	 * @param string $value
1309
	 *
1310
	 * @throws MapperArgumentException
1311
	 *
1312
	 * @return void
1313
	 */
1314
	public function setClustersIcon($value)
1315
	{
1316
		if (!is_string($value)) {
1317
			throw new MapperArgumentException('Invalid map clusters icon setting.');
1318
		}
1319
1320
		$this->clustersIcon = $value;
0 ignored issues
show
Documentation Bug introduced by
It seems like $value of type string is incompatible with the declared type array of property $clustersIcon.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1321
	}
1322
1323
	/**
1324
	 * Get map clusters icon.
1325
	 *
1326
	 * @return string
1327
	 */
1328
	public function getClustersIcon()
1329
	{
1330
		return $this->clustersIcon;
1331
	}
1332
1333
	/**
1334
	 * Set map cluster grid.
1335
	 *
1336
	 * @param integer $value
1337
	 *
1338
	 * @throws MapperArgumentException
1339
	 *
1340
	 * @return void
1341
	 */
1342
	public function setClustersGrid($value)
1343
	{
1344
		if (!is_integer($value)) {
1345
			throw new MapperArgumentException('Invalid map clusters grid setting.');
1346
		}
1347
1348
		$this->clustersGrid = $value;
1349
	}
1350
1351
	/**
1352
	 * Get map cluster grid.
1353
	 *
1354
	 * @return integer
1355
	 */
1356
	public function getClustersGrid()
1357
	{
1358
		return $this->clustersGrid;
1359
	}
1360
1361
	/**
1362
	 * Set map cluster zoom.
1363
	 *
1364
	 * @param integer|null $value
1365
	 *
1366
	 * @throws MapperArgumentException
1367
	 *
1368
	 * @return void
1369
	 */
1370
	public function setClustersZoom($value)
1371
	{
1372
		if (!is_integer($value) && !is_null($value)) {
1373
			throw new MapperArgumentException('Invalid map clusters zoom setting.');
1374
		}
1375
1376
		$this->clustersZoom = $value;
1377
	}
1378
1379
	/**
1380
	 * Get map cluster grid.
1381
	 *
1382
	 * @return integer|null
1383
	 */
1384
	public function getClustersZoom()
1385
	{
1386
		return $this->clustersZoom;
1387
	}
1388
1389
	/**
1390
	 * Set map cluster center.
1391
	 *
1392
	 * @param boolean $value
1393
	 *
1394
	 * @throws MapperArgumentException
1395
	 *
1396
	 * @return void
1397
	 */
1398
	public function setClustersCenter($value)
1399
	{
1400
		if (!is_bool($value)) {
1401
			throw new MapperArgumentException('Invalid map clusters center setting.');
1402
		}
1403
1404
		$this->clustersCenter = $value;
1405
	}
1406
1407
	/**
1408
	 * Get map cluster center.
1409
	 *
1410
	 * @return boolean
1411
	 */
1412
	public function getClustersCenter()
1413
	{
1414
		return $this->clustersCenter;
1415
	}
1416
1417
	/**
1418
	 * Set map cluster size.
1419
	 *
1420
	 * @param integer $value
1421
	 *
1422
	 * @throws MapperArgumentException
1423
	 *
1424
	 * @return void
1425
	 */
1426
	public function setClustersSize($value)
1427
	{
1428
		if (!is_integer($value)) {
1429
			throw new MapperArgumentException('Invalid map clusters size setting.');
1430
		}
1431
1432
		$this->clustersSize = $value;
1433
	}
1434
1435
	/**
1436
	 * Get map cluster size.
1437
	 *
1438
	 * @return integer
1439
	 */
1440
	public function getClustersSize()
1441
	{
1442
		return $this->clustersSize;
1443
	}
1444
1445
	/**
1446
	 * Get mapper options.
1447
	 *
1448
	 * @return array
1449
	 */
1450
	protected function getOptions()
1451
	{
1452
		return [
1453
			'key' => $this->getKey(),
1454
			'version' => $this->version,
1455
			'region' => $this->getRegion(),
1456
			'language' => $this->getLanguage(),
1457
			'user' => $this->getUser(),
1458
			'marker' => $this->getMarker(),
1459
			'center' => $this->getCenter(),
1460
			'locate' => $this->getLocate(),
1461
			'zoom' => $this->getZoom(),
1462
			'scrollWheelZoom' => $this->getScrollWheelZoom(),
1463
			'type' => $this->getType(),
1464
			'tilt' => $this->getTilt(),
1465
			'ui' => $this->getUi(),
1466
			'overlay' => '',
1467
			'markers' => [
1468
				'title' => '',
1469
				'content' => '',
1470
				'icon' => $this->getIcon(),
1471
				'place' => '',
1472
				'animation' => $this->getAnimation(),
1473
				'symbol' => '',
1474
			],
1475
			'cluster' => $this->getCluster(),
1476
			'clusters' => [
1477
				'icon' => $this->getClustersIcon(),
1478
				'grid' => $this->getClustersGrid(),
1479
				'zoom' => $this->getClustersZoom(),
1480
				'center' => $this->getClustersCenter(),
1481
				'size' => $this->getClustersSize()
1482
			],
1483
		];
1484
	}
1485
1486
	/**
1487
	 * Add mapping item.
1488
	 *
1489
	 * @param object $value
1490
	 *
1491
	 * @return void
1492
	 */
1493
	protected function addItem($value)
1494
	{
1495
		$this->items[] = $value;
1496
	}
1497
1498
	/**
1499
	 * Set mapping items.
1500
	 *
1501
	 * @param array $array
1502
	 *
1503
	 * @return void
1504
	 */
1505
	protected function setItems(array $array)
1506
	{
1507
		$this->items = $array;
1508
	}
1509
1510
	/**
1511
	 * Get the mapping items.
1512
	 *
1513
	 * @return array
1514
	 */
1515
	public function getItems()
1516
	{
1517
		return $this->items;
1518
	}
1519
1520
	/**
1521
	 * Get a mapping item by reference.
1522
	 *
1523
	 * @param integer $item
1524
	 *
1525
	 * @return array|boolean
1526
	 */
1527
	public function getItem($item)
1528
	{
1529
		return isset($this->items[$item]) ? $this->items[$item] : false;
1530
	}
1531
1532
}