Passed
Branch master (41ef34)
by Roberto
04:08
created

LatLng::getLat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Copyright (c) 2018 - present
4
 * Google Maps PHP - LatLng.php
5
 * author: Roberto Belotti - [email protected]
6
 * web : robertobelotti.com, github.com/biscolab
7
 * Initial version created on: 5/9/2018
8
 * MIT license: https://github.com/biscolab/google-maps-php/blob/master/LICENSE
9
 */
10
11
namespace Biscolab\GoogleMaps\Object;
12
13
use Biscolab\GoogleMaps\Abstracts\AbstractObject;
14
use Biscolab\GoogleMaps\Fields\LatLngFields;
15
16
/**
17
 * Class LatLng
18
 * @method LatLng setLat($args)
19
 * @method LatLng setLng($args)
20
 * @package Biscolab\GoogleMaps\Object
21
 */
22
class LatLng extends AbstractObject {
23
24
	/**
25
	 * @var float
26
	 */
27
	protected $lat = 0;
28
29
	/**
30
	 * @var float
31
	 */
32
	protected $lng = 0;
33
34
	/**
35
	 * @var array
36
	 */
37
	protected $typeCheck = [
38
		LatLngFields::LAT => 'float',
39
		LatLngFields::LNG => 'float',
40
	];
41
42
	/**
43
	 * Return the latitude, 0 if null
44
	 *
45
	 * @return string
46
	 */
47
	public function getLat(): string {
48
49
		return $this->lat ?? 0;
50
	}
51
52
	/**
53
	 * Return the longitude, 0 if null
54
	 *
55
	 * @return string
56
	 */
57
	public function getLng(): string {
58
59
		return $this->lng ?? 0;
60
	}
61
62
	/**
63
	 * @return string
64
	 */
65
	public function __toString(): string {
66
67
		return implode(',', [
68
			$this->getLat(),
69
			$this->getLng()
70
		]);
71
	}
72
73
}