matchIp() public method

Adds a check for the client IP.
public matchIp ( string $ip )
$ip string A specific IP address or a range specified using IP/netmask like 192.168.1.0/24
 public function testIp()
 {
     $matcher = new RequestMatcher();
     $matcher->matchIp('192.168.1.1/1');
     $request = Request::create('', 'get', array(), array(), array(), array('REMOTE_ADDR' => '192.168.1.1'));
     $this->assertTrue($matcher->matches($request));
     $matcher->matchIp('192.168.1.0/24');
     $this->assertTrue($matcher->matches($request));
     $matcher->matchIp('1.2.3.4/1');
     $this->assertFalse($matcher->matches($request));
 }
 /**
  * @dataProvider testIpProvider
  */
 public function testIp($matches, $remoteAddr, $cidr)
 {
     $request = Request::create('', 'get', array(), array(), array(), array('REMOTE_ADDR' => $remoteAddr));
     $matcher = new RequestMatcher();
     $matcher->matchIp($cidr);
     $this->assertEquals($matches, $matcher->matches($request));
 }
 public function testAnIpv6WithOptionDisabledIpv6()
 {
     if (defined('AF_INET6')) {
         $this->markTestSkipped('Only works when PHP is compiled with the option "disable-ipv6".');
     }
     $request = Request::create('', 'get', array(), array(), array(), array('REMOTE_ADDR' => '2a01:198:603:0:396e:4789:8e99:890f'));
     $matcher = new RequestMatcher();
     $matcher->matchIp('2a01:198:603:0::/65');
     try {
         $matcher->matches($request);
         $this->fail('An expected RuntimeException has not been raised.');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\RuntimeException', $e);
     }
 }