CoordinatesObject::setLatitude()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace ZpgRtf\Objects;
4
5
/**
6
 * This object describes the geographic location of a point on the Earth's surface using the latitude/longitude system.
7
 * ZPG recommends you store latitude/longitude with a precision of at least 5 decimal places, which allows for locating
8
 * a point to within approximately 1 metre.
9
 */
10
class CoordinatesObject implements \JsonSerializable
11
{
12
    /** @var null|float */
13
    private $latitude;
14
15
    /** @var null|float */
16
    private $longitude;
17
18
    /**
19
     * @return null|float
20
     */
21 4
    public function getLatitude()
22
    {
23 4
        return $this->latitude;
24
    }
25
26
    /**
27
     * @param float $latitude
28
     *
29
     * @return CoordinatesObject
30
     */
31 3
    public function setLatitude(float $latitude): self
32
    {
33 3
        $this->latitude = $latitude;
34
35 3
        return $this;
36
    }
37
38
    /**
39
     * @return null|float
40
     */
41 4
    public function getLongitude()
42
    {
43 4
        return $this->longitude;
44
    }
45
46
    /**
47
     * @param float $longitude
48
     *
49
     * @return CoordinatesObject
50
     */
51 3
    public function setLongitude(float $longitude): self
52
    {
53 3
        $this->longitude = $longitude;
54
55 3
        return $this;
56
    }
57
58
    /** {@inheritDoc} */
59 3
    public function jsonSerialize(): array
60
    {
61 3
        return array_filter([
62 3
            'latitude' => $this->getLatitude(),
63 3
            'longitude' => $this->getLongitude(),
64
        ]);
65
    }
66
}
67