diff --git a/src/GpsPoint.php b/src/GpsPoint.php index 3078b68c..dd3fcb5b 100644 --- a/src/GpsPoint.php +++ b/src/GpsPoint.php @@ -53,7 +53,7 @@ private function isValidCoordinate(string $value, float $maxBoundary): bool $value = $this->removeDegreeSign($value); } - if ($value === false || $value === null) { + if ($value === false || $value === null || !is_numeric($value)) { $this->error(self::CONVERT_ERROR); return false; } diff --git a/test/GPSPointTest.php b/test/GPSPointTest.php index efbd47fe..83284c2a 100644 --- a/test/GPSPointTest.php +++ b/test/GPSPointTest.php @@ -85,10 +85,11 @@ public function basicDataProvider(): array public function errorMessageTestValues(): array { return [ - ['63 47 24.691 N, 18 2 54.363 W', GpsPoint::OUT_OF_BOUNDS, '63 47 24.691 N'], + ['63 47 24.691 N, 18 2 54.363 W', GpsPoint::CONVERT_ERROR, '63 47 24.691 N'], + ['65° 4\' N,-22.728867530822754', GpsPoint::CONVERT_ERROR, '65° 4\' N'], ['° \' " N,° \' " E', GpsPoint::CONVERT_ERROR, '° \' " N'], ['° \' " N', GpsPoint::INCOMPLETE_COORDINATE, '° \' " N'], - ['foo,bar', GpsPoint::CONVERT_ERROR, '° \' " N'], + ['foo,bar', GpsPoint::CONVERT_ERROR, 'foo'], ]; } }