Symfony\Component\HttpFoundation\RequestMatcher::matchIp PHP Method

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 matchIp($ip)
    {
        $this->ip = $ip;
    }

Usage Example

 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));
 }
All Usage Examples Of Symfony\Component\HttpFoundation\RequestMatcher::matchIp