Skip to content

Commit

Permalink
bug: laminas#135 Add numeric state test to check if string is a real …
Browse files Browse the repository at this point in the history
…number

Signed-off-by: codisart <[email protected]>
  • Loading branch information
codisart committed Jan 12, 2023
1 parent aba4be7 commit 6be9176
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/GpsPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions test/GPSPointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,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'],
];
}
}

0 comments on commit 6be9176

Please sign in to comment.