public function match($request, &$hostVariables = null)
    {
        $defaults = [
            'host'   => '*',
            'scheme' => '*'
        ];
        $request += $defaults;
        $scheme = $request['scheme'];
        $host = $request['host'];

        $hostVariables = [];

        $anyHost = $this->pattern() === '*' || $host === '*';
        $anyScheme = $this->scheme() === '*' || $scheme === '*';


        if ($anyHost) {
            if ($this->variables()) {
                $hostVariables = array_fill_keys(array_keys($this->variables()), null);
            }
            return $anyScheme || $this->scheme() === $scheme;
        }

        if (!$anyScheme && $this->scheme() !== $scheme) {
            return false;
        }

        if (!preg_match('~^' . $this->regex() . '$~', $host, $matches)) {
            $hostVariables = null;
            return false;
        }
        $i = 0;

        foreach ($this->variables() as $name => $pattern) {
            $hostVariables[$name] = $matches[++$i];
        }
        return true;
    }
public function match($request, &$hostVariables = null)
    {
        $defaults = [
            'host'   => '*',
            'scheme' => '*'
        ];
        $request += $defaults;
        $scheme = $request['scheme'];
        $host = $request['host'];

        $hostVariables = [];

        $anyHost = $this->pattern() === '*' || $host === '*';
        $anyScheme = $this->scheme() === '*' || $scheme === '*';


        if ($anyHost) {
            if ($this->variables()) {
                $hostVariables = array_fill_keys(array_keys($this->variables()), null);
            }
            return $anyScheme || $this->scheme() === $scheme;
        }

        if (!$anyScheme && $this->scheme() !== $scheme) {
            return false;
        }

        if (!preg_match('~^' . $this->regex() . '$~', $host, $matches)) {
            $hostVariables = null;
            return false;
        }
        $i = 0;

        foreach ($this->variables() as $name => $pattern) {
            $hostVariables[$name] = $matches[++$i];
        }
        return true;
    }
public function match ( $ request , & $ hostVariables = null ) { $ defaults = [ 'host' => '*' , 'scheme' => '*' ] ; $ request += $ defaults ; $ scheme = $ request [ 'scheme' ] ; $ host = $ request [ 'host' ] ; $ hostVariables = [ ] ; $ anyHost = $ this -> pattern ( ) === '*' || $ host === '*' ; $ anyScheme = $ this -> scheme ( ) === '*' || $ scheme === '*' ; if ( $ anyHost ) { if ( $ this -> variables ( ) ) { $ hostVariables = array_fill_keys ( array_keys ( $ this -> variables ( ) ) , null ) ; } return $ anyScheme || $ this -> scheme ( ) === $ scheme ; } if ( ! $ anyScheme && $ this -> scheme ( ) !== $ scheme ) { return false ; } if ( ! preg_match ( '~^' . $ this -> regex ( ) . '$~' , $ host , $ matches ) ) { $ hostVariables = null ; return false ; } $ i = 0 ; foreach ( $ this -> variables ( ) as $ name => $ pattern ) { $ hostVariables [ $ name ] = $ matches [ ++ $ i ] ; } return true ; }
Checks if a host matches a host pattern.

@param  string  $host          The host to check.
@param  string  $hostVariables The matches host variables
@return boolean                Returns `true` on success, false otherwise.
Checks if a host matches a host pattern .