Skip to content

Commit

Permalink
fix variable name in Countries::ip method
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvankooten committed Jan 8, 2019
1 parent 95e0425 commit e5092c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,11 @@ public function inEurope(string $code) : bool
*/
public function ip(string $ipAddress) : string
{
$url = 'https://ip2c.org/' . $ip;
if (empty($ipAddress)) {
return '';
}

$url = sprintf('https://ip2c.org/%s', urlencode($ipAddress));

$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $url);
Expand Down
8 changes: 8 additions & 0 deletions tests/CountriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,13 @@ public function testInEurope() {
self::assertTrue( $countries->inEurope( $country ) );
}
}

/**
* @covers Countries::ip
*/
public function testIp() {
$countries = new Countries();
self::assertEmpty($countries->ip(''));
}

}

0 comments on commit e5092c5

Please sign in to comment.