Passed
Push — 4.x ( 17e0c5...e9b635 )
by Doug
07:44
created

GeographicValue   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 10
c 1
b 0
f 0
dl 0
loc 37
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getLongitude() 0 3 1
A getLatitude() 0 3 1
A getHeight() 0 3 2
1
<?php
2
/**
3
 * PHPCoord.
4
 *
5
 * @author Doug Wright
6
 */
7
declare(strict_types=1);
8
9
namespace PHPCoord\CoordinateOperation;
10
11
use PHPCoord\UnitOfMeasure\Angle\Angle;
12
use PHPCoord\UnitOfMeasure\Angle\Radian;
13
use PHPCoord\UnitOfMeasure\Length\Length;
14
use PHPCoord\UnitOfMeasure\Length\Metre;
15
16
/**
17
 * A geographic point w/out a CRS.
18
 * @internal
19
 */
20
class GeographicValue
21
{
22
    /**
23
     * @var Angle
24
     */
25
    private $latitude;
26
27
    /**
28
     * @var Angle
29
     */
30
    private $longitude;
31
32
    /**
33
     * @var Length
34
     */
35
    private $height;
36
37 11
    public function __construct(Angle $latitude, Angle $longitude, ?Length $height)
38
    {
39 11
        $this->latitude = $latitude;
40 11
        $this->longitude = $longitude;
41 11
        $this->height = $height;
42 11
    }
43
44 11
    public function getLatitude(): Radian
45
    {
46 11
        return $this->latitude->asRadians();
47
    }
48
49 11
    public function getLongitude(): Radian
50
    {
51 11
        return $this->longitude->asRadians();
52
    }
53
54 11
    public function getHeight(): Metre
55
    {
56 11
        return $this->height ? $this->height->asMetres() : new Metre(0);
57
    }
58
}
59