public function matchHeader($name, $pattern = null)
    {
        if (isset($this->getHeaders()[$name])) {
            if (!empty($pattern)) {
                if ($this->matchValue($this->getHeaders()[$name], $pattern)) {
                    return $this->getHeaders()[$name];
                }
            } else {
                if (empty($this->getHeaders()[$name])) {
                    return true;
                } else {
                    return $this->getHeaders()[$name];
                }
            }
        } elseif ($pattern == '?') {
            // in case of optional pattern we just return true
            return true;
        }

        return false;
    }
public function matchHeader($name, $pattern = null)
    {
        if (isset($this->getHeaders()[$name])) {
            if (!empty($pattern)) {
                if ($this->matchValue($this->getHeaders()[$name], $pattern)) {
                    return $this->getHeaders()[$name];
                }
            } else {
                if (empty($this->getHeaders()[$name])) {
                    return true;
                } else {
                    return $this->getHeaders()[$name];
                }
            }
        } elseif ($pattern == '?') {
            // in case of optional pattern we just return true
            return true;
        }

        return false;
    }
public function matchHeader ( $ name , $ pattern = null ) { if ( isset ( $ this -> getHeaders ( ) [ $ name ] ) ) { if ( ! empty ( $ pattern ) ) { if ( $ this -> matchValue ( $ this -> getHeaders ( ) [ $ name ] , $ pattern ) ) { return $ this -> getHeaders ( ) [ $ name ] ; } } else { if ( empty ( $ this -> getHeaders ( ) [ $ name ] ) ) { return true ; } else { return $ this -> getHeaders ( ) [ $ name ] ; } } } elseif ( $ pattern == '?' ) { // in case of optional pattern we just return true return true ; } return false ; }
Check if the given header exists, and optionally if the pattern matches the header value.

@param string      $name Header name to match.
@param string|null $pattern Optional pattern that needs to match the header value.

@return bool|string  False if the header doesn't exist, or the pattern doesn't match.
If the header exists and pattern matched, the header value is returned.
Check if the given header exists and optionally if the pattern matches the header value .