LatLng::getLng()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
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
	/**
26
	 * @var float
27
	 */
28
	protected $lat = 0;
29
30
	/**
31
	 * @var float
32
	 */
33
	protected $lng = 0;
34
35
	/**
36
	 * @var array
37
	 */
38
	protected $typeCheck = [
39
		LatLngFields::LAT => 'float',
40
		LatLngFields::LNG => 'float',
41
	];
42
43
	/**
44
	 * @return string
45
	 */
46 5
	public function __toString(): string
47
	{
48
49 5
		return implode(',', [
50 5
			$this->getLat(),
51 5
			$this->getLng()
52
		]);
53
	}
54
55
	/**
56
	 * Return the latitude, 0 if null
57
	 *
58
	 * @return string
59
	 */
60 9
	public function getLat(): string
61
	{
62
63 9
		return $this->lat ?? 0;
64
	}
65
66
	/**
67
	 * Return the longitude, 0 if null
68
	 *
69
	 * @return string
70
	 */
71 9
	public function getLng(): string
72
	{
73
74 9
		return $this->lng ?? 0;
75
	}
76
77
}