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

GeographicValue::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 3
crap 1
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