Total Complexity | 14 |
Total Lines | 77 |
Duplicated Lines | 0 % |
Coverage | 91.89% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
25 | class GeographicValue |
||
26 | { |
||
27 | private $latitude; |
||
28 | |||
29 | private $longitude; |
||
30 | |||
31 | private $height; |
||
32 | |||
33 | private $datum; |
||
34 | |||
35 | 50 | public function __construct(Angle $latitude, Angle $longitude, ?Length $height, Datum $datum) |
|
36 | { |
||
37 | 50 | $this->latitude = $this->normaliseLatitude($latitude)->asRadians(); |
|
38 | 50 | $this->longitude = $this->normaliseLongitude($longitude)->asRadians(); |
|
39 | 50 | $this->datum = $datum; |
|
40 | |||
41 | 50 | $this->height = $height ? $height->asMetres() : null; |
|
42 | 50 | } |
|
43 | |||
44 | 46 | public function getLatitude(): Radian |
|
45 | { |
||
46 | 46 | return $this->latitude; |
|
47 | } |
||
48 | |||
49 | 46 | public function getLongitude(): Radian |
|
52 | } |
||
53 | |||
54 | 12 | public function getHeight(): ?Metre |
|
55 | { |
||
56 | 12 | return $this->height; |
|
57 | } |
||
58 | |||
59 | 2 | public function getDatum(): Datum |
|
60 | { |
||
61 | 2 | return $this->datum; |
|
62 | } |
||
63 | |||
64 | 28 | public function asGeocentricValue(): GeocentricValue |
|
65 | { |
||
66 | 28 | $a = $this->datum->getEllipsoid()->getSemiMajorAxis()->asMetres()->getValue(); |
|
67 | 28 | $e2 = $this->datum->getEllipsoid()->getEccentricitySquared(); |
|
68 | 28 | $latitude = $this->latitude->getValue(); |
|
69 | 28 | $longitude = $this->longitude->getValue() - $this->datum->getPrimeMeridian()->getGreenwichLongitude()->asRadians()->getValue(); |
|
70 | 28 | $h = isset($this->height) ? $this->height->getValue() : 0; |
|
|
|||
71 | |||
72 | 28 | $nu = $a / sqrt(1 - $e2 * (sin($latitude) ** 2)); |
|
73 | 28 | $x = ($nu + $h) * cos($latitude) * cos($longitude); |
|
74 | 28 | $y = ($nu + $h) * cos($latitude) * sin($longitude); |
|
75 | 28 | $z = ((1 - $e2) * $nu + $h) * sin($latitude); |
|
76 | |||
77 | 28 | return new GeocentricValue(new Metre($x), new Metre($y), new Metre($z), $this->datum); |
|
78 | } |
||
79 | |||
80 | 50 | protected function normaliseLatitude(Angle $latitude): Angle |
|
90 | } |
||
91 | |||
92 | 50 | protected function normaliseLongitude(Angle $longitude): Angle |
|
102 | } |
||
103 | } |
||
104 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.