Lines
100.00%
4 / 4
Methods
100.00%
1 / 1
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 3 | ||
| 10 | final readonly class GeoLocation | |
| 11 | { | |
| 12 | private const int LATITUDE_LIMIT = 90; | |
| 13 | private const int LONGITUDE_LIMIT = 180; | |
| 14 | ||
| 15 | /** @throws SunException */ | |
| 16 | public function __construct( | |
| 17 | public float $latitude, | |
| 18 | public float $longitude, | |
| 19 | public float $elevationMeters = 0.0, | |
| 20 | ) { | |
| 21 | if (abs($latitude) > self::LATITUDE_LIMIT) { | |
| 22 | throw SunException::createForReason(SunError::CoordinateOutOfRange, coordinate: 'latitude', value: $latitude, limit: self::LATITUDE_LIMIT); | |
| 23 | } | |
| 24 | ||
| 25 | if (abs($longitude) > self::LONGITUDE_LIMIT) { | |
| 26 | throw SunException::createForReason(SunError::CoordinateOutOfRange, coordinate: 'longitude', value: $longitude, limit: self::LONGITUDE_LIMIT); | |
| 27 | } | |
| 28 | } | |
| 29 | } |