Passed
Push — master ( fd93b5...48e916 )
by Doug
40:26 queued 29:39
created

NADCON5Grids::__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
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 1
b 0
f 0
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\ArcSecond;
12
use PHPCoord\UnitOfMeasure\Length\Metre;
13
14
class NADCON5Grids extends GeographicGrid
15
{
16
    private NADCON5Grid $longitudeGrid;
17
    private NADCON5Grid $latitudeGrid;
18
    private ?NADCON5Grid $ellipsoidHeightGrid;
19
20 7
    public function __construct(NADCON5Grid $longitudeGrid, NADCON5Grid $latitudeGrid, ?NADCON5Grid $ellipsoidHeightGrid)
21
    {
22 7
        $this->longitudeGrid = $longitudeGrid;
23 7
        $this->latitudeGrid = $latitudeGrid;
24 7
        $this->ellipsoidHeightGrid = $ellipsoidHeightGrid;
25 7
    }
26
27 7
    public function getValues(float $x, float $y): array
28
    {
29 7
        $latitudeShift = new ArcSecond($this->latitudeGrid->getValues($x, $y)[0]);
30 7
        $longitudeShift = new ArcSecond($this->longitudeGrid->getValues($x, $y)[0]);
31 7
        $heightShift = $this->ellipsoidHeightGrid ? new Metre($this->ellipsoidHeightGrid->getValues($x, $y)[0]) : null;
32
33 7
        return [$latitudeShift, $longitudeShift, $heightShift];
34
    }
35
}
36