Skip to content

Commit

Permalink
Codestyle!
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Smet committed Mar 10, 2024
1 parent 36fa39e commit 7e41368
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/Validators/Rules/IsLatitude.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

final class IsLatitude extends IsFloat
{
private float $min = -90.0;
private float $max = 90.0;

public function validateRule(?string $cellValue): ?string
{
if (!$this->getOptionAsBool()) {
Expand All @@ -30,8 +33,8 @@ public function validateRule(?string $cellValue): ?string
}

$latitude = (float)$cellValue;
if ($latitude < -90.0 || $latitude > 90.0) {
return "Value \"{$cellValue}\" is not a valid latitude (-90 <= x <= 90)";
if ($latitude < $this->min || $latitude > $this->max) {
return "Value \"{$cellValue}\" is not a valid latitude ({$this->min} <= x <= {$this->max})";
}

return null;
Expand Down
9 changes: 6 additions & 3 deletions src/Validators/Rules/IsLongitude.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

final class IsLongitude extends IsFloat
{
private float $min = -180.0;
private float $max = 180.0;

public function validateRule(?string $cellValue): ?string
{
if (!$this->getOptionAsBool()) {
Expand All @@ -29,9 +32,9 @@ public function validateRule(?string $cellValue): ?string
return $result;
}

$latitude = (float)$cellValue;
if ($latitude < -180.0 || $latitude > 180.0) {
return "Value \"{$cellValue}\" is not a valid longitude (-180 <= x <= 180)";
$longitude = (float)$cellValue;
if ($longitude < $this->min || $longitude > $this->max) {
return "Value \"{$cellValue}\" is not a valid longitude ({$this->min} <= x <= {$this->max})";
}

return null;
Expand Down

0 comments on commit 7e41368

Please sign in to comment.