Skip to content

Commit bdfbcc8

Browse files
authored
Added custom address for Geonames (#695)
* Added custom address for Geonames * Applied changes from StyleCI * Bugfix
1 parent 3face59 commit bdfbcc8

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Assert.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ public static function longitude($value, $message = '')
5252
}
5353
}
5454

55+
/**
56+
* @param mixed $value
57+
* @param string $message
58+
*/
59+
public static function notNull($value, $message = '')
60+
{
61+
if (null === $value) {
62+
throw new \InvalidArgumentException(sprintf($message ?: 'Value cannot be null'));
63+
}
64+
}
65+
5566
private static function typeToString($value)
5667
{
5768
return is_object($value) ? get_class($value) : gettype($value);

Model/Coordinates.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ final class Coordinates
3535
*/
3636
public function __construct($latitude, $longitude)
3737
{
38+
Assert::notNull($latitude);
39+
Assert::notNull($longitude);
40+
3841
$latitude = (float) $latitude;
3942
$longitude = (float) $longitude;
4043

0 commit comments

Comments
 (0)