matchIps example

/** * @param string|string[]|null $methods * @param string|string[]|null $ips * @param string|string[]|null $schemes */
    public function __construct(string $path = null, string $host = null, string|array $methods = null, string|array $ips = null, array $attributes = [], string|array $schemes = null, int $port = null)
    {
        $this->matchPath($path);
        $this->matchHost($host);
        $this->matchMethod($methods);
        $this->matchIps($ips);
        $this->matchScheme($schemes);
        $this->matchPort($port);

        foreach ($attributes as $k => $v) {
            $this->matchAttribute($k$v);
        }
    }

    /** * Adds a check for the HTTP scheme. * * @param string|string[]|null $scheme An HTTP scheme or an array of HTTP schemes * * @return void */

        $matcher = new RequestMatcher();

        $request = Request::create('', 'GET', [][][]['REMOTE_ADDR' => '127.0.0.1']);

        $matcher->matchIp('127.0.0.1');
        $this->assertTrue($matcher->matches($request));

        $matcher->matchIp('192.168.0.1');
        $this->assertFalse($matcher->matches($request));

        $matcher->matchIps('127.0.0.1');
        $this->assertTrue($matcher->matches($request));

        $matcher->matchIps('127.0.0.1, ::1');
        $this->assertTrue($matcher->matches($request));

        $matcher->matchIps('192.168.0.1, ::1');
        $this->assertFalse($matcher->matches($request));

        $matcher->matchIps(['127.0.0.1', '::1']);
        $this->assertTrue($matcher->matches($request));

        
/** * @param string|string[]|null $methods * @param string|string[]|null $ips * @param string|string[]|null $schemes */
    public function __construct(string $path = null, string $host = null, string|array $methods = null, string|array $ips = null, array $attributes = [], string|array $schemes = null, int $port = null)
    {
        $this->matchPath($path);
        $this->matchHost($host);
        $this->matchMethod($methods);
        $this->matchIps($ips);
        $this->matchScheme($schemes);
        $this->matchPort($port);

        foreach ($attributes as $k => $v) {
            $this->matchAttribute($k$v);
        }
    }

    /** * Adds a check for the HTTP scheme. * * @param string|string[]|null $scheme An HTTP scheme or an array of HTTP schemes * * @return void */
Home | Imprint | This part of the site doesn't use cookies.