From 1d24382454481384bbc987dcbc959cfef17d6baa Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Tue, 8 Jan 2019 10:21:39 +0100 Subject: [PATCH] move empty check to validateIpAddress method --- src/Countries.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Countries.php b/src/Countries.php index fbfd5e4..f0f6a28 100644 --- a/src/Countries.php +++ b/src/Countries.php @@ -368,6 +368,10 @@ public function validateCountryCode(string $countryCode) : bool */ public function validateIpAddress(string $ipAddress) : bool { + if (empty($ipAddress)) { + return false; + } + return (bool) filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE); } @@ -382,7 +386,7 @@ public function validateIpAddress(string $ipAddress) : bool */ public function ip(string $ipAddress) : string { - if (empty($ipAddress) || !$this->validateIpAddress($ipAddress)) { + if (!$this->validateIpAddress($ipAddress)) { return ''; }