summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoffrey Jaffeux <j.jaffeux@gmail.com>2012-06-06 15:47:22 +0200
committerJoffrey Jaffeux <j.jaffeux@gmail.com>2012-06-06 15:47:22 +0200
commit908f36a583384b0314d04c4cfe71992746e35daa (patch)
treedf4292dc45591ec8f03c89ea928de38bd2fa2e4a
parent0723617703dda3660597d9cdef59e7cdded1c497 (diff)
ip_version() now returns int instead of string
-rwxr-xr-xsystem/core/Input.php6
-rw-r--r--tests/codeigniter/core/Input_test.php4
2 files changed, 5 insertions, 5 deletions
diff --git a/system/core/Input.php b/system/core/Input.php
index ac67aaf4f..36ff96d03 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -383,7 +383,7 @@ class CI_Input {
*/
public function valid_ip($ip)
{
- if ($this->ip_version($ip) === '4')
+ if ($this->ip_version($ip) === 4)
{
return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
}
@@ -399,11 +399,11 @@ class CI_Input {
* Return ip version
*
* @param string
- * @return string
+ * @return int
*/
public function ip_version($ip)
{
- return strpos($ip, ":") === false ? '4' : '6';
+ return strpos($ip, ":") === false ? 4 : 6;
}
// --------------------------------------------------------------------
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
index 2aa3a6246..98d6299f8 100644
--- a/tests/codeigniter/core/Input_test.php
+++ b/tests/codeigniter/core/Input_test.php
@@ -163,12 +163,12 @@ class Input_test extends CI_TestCase {
public function test_ip_version()
{
$ip_v4 = '175.123.74.43';
- $this->assertEquals('4', $this->input->ip_version($ip_v4));
+ $this->assertEquals(4, $this->input->ip_version($ip_v4));
$ip_v6 = array('2001:0db8:0000:85a3:0000:0000:ac1f:8001', '2001:db8:0:85a3:0:0:ac1f:8001', '2001:db8:0:85a3::ac1f:8001');
foreach($ip_v6 as $ip)
{
- $this->assertEquals('6', $this->input->ip_version($ip));
+ $this->assertEquals(6, $this->input->ip_version($ip));
}
}