Psr7Middlewares\Middleware\DigestAuthentication::parseAuthorizationHeader PHP Метод

parseAuthorizationHeader() приватный статический Метод

Parses the authorization header for a basic authentication.
private static parseAuthorizationHeader ( string $header ) : false | array
$header string
Результат false | array
    private static function parseAuthorizationHeader($header)
    {
        if (strpos($header, 'Digest') !== 0) {
            return false;
        }
        $needed_parts = ['nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1];
        $data = [];
        preg_match_all('@(' . implode('|', array_keys($needed_parts)) . ')=(?:([\'"])([^\\2]+?)\\2|([^\\s,]+))@', substr($header, 7), $matches, PREG_SET_ORDER);
        if ($matches) {
            foreach ($matches as $m) {
                $data[$m[1]] = $m[3] ? $m[3] : $m[4];
                unset($needed_parts[$m[1]]);
            }
        }
        return empty($needed_parts) ? $data : false;
    }