Passed
Push — 4.x ( c37faa...bd875a )
by Doug
12:53
created

VerticalPoint   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 37
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getHeight() 0 3 1
A __construct() 0 4 1
A getCRS() 0 3 1
A __toString() 0 3 1
1
<?php
2
/**
3
 * PHPCoord.
4
 *
5
 * @author Doug Wright
6
 */
7
declare(strict_types=1);
8
9
namespace PHPCoord;
10
11
use PHPCoord\CoordinateReferenceSystem\CoordinateReferenceSystem;
12
use PHPCoord\CoordinateReferenceSystem\Vertical;
13
use PHPCoord\UnitOfMeasure\Length\Length;
14
use PHPCoord\UnitOfMeasure\UnitOfMeasureFactory;
15
16
/**
17
 * Coordinate representing a vertical dimension.
18
 * @author Doug Wright
19
 */
20
class VerticalPoint extends Point
21
{
22
    /**
23
     * Height.
24
     * @var Length
25
     */
26
    protected $height;
27
28
    /**
29
     * Coordinate reference system.
30
     * @var CoordinateReferenceSystem
31
     */
32
    protected $crs;
33
34
    /**
35
     * Constructor.
36
     * @param Length $height refer to CRS for preferred unit of measure, but any length unit accepted
37
     */
38
    public function __construct(Length $height, Vertical $crs)
39
    {
40
        $this->height = UnitOfMeasureFactory::convertLength($height, $crs->getCoordinateSystem()->getAxes()[1]->getUnitOfMeasureId());
41
        $this->crs = $crs;
42
    }
43
44
    public function getHeight(): Length
45
    {
46
        return $this->height;
47
    }
48
49
    public function getCRS(): CoordinateReferenceSystem
50
    {
51
        return $this->crs;
52
    }
53
54
    public function __toString(): string
55
    {
56
        return "({$this->height})";
57
    }
58
}
59