add type hinting in Point and PointException

This commit is contained in:
nobohan 2021-04-22 09:45:12 +02:00
parent 7c99f0b3e0
commit e90ea31683

View File

@ -13,7 +13,7 @@ class Point implements JsonSerializable {
private float $lon;
public static string $SRID = '4326';
private function __construct($lon, $lat)
private function __construct(float $lon, float $lat)
{
$this->lat = $lat;
$this->lon = $lon;
@ -52,7 +52,7 @@ class Point implements JsonSerializable {
* @param type $geojson
* @return Point
*/
public static function fromGeoJson($geojson): Point
public static function fromGeoJson(string $geojson): Point
{
$a = json_decode($geojson);
//check if the geojson string is correct
@ -70,7 +70,7 @@ class Point implements JsonSerializable {
}
public static function fromLonLat($lon, $lat): Point
public static function fromLonLat(float $lon, float $lat): Point
{
if (($lon > -180 && $lon < 180) && ($lat > -90 && $lat < 90))
{
@ -80,7 +80,7 @@ class Point implements JsonSerializable {
}
}
public static function fromArrayGeoJson($array): Point
public static function fromArrayGeoJson(array $array): Point
{
if ($array['type'] == 'Point' &&
isset($array['coordinates']))