public function digest($string)
    {
        // protect against missing data
        $needed = array(
            'nonce' => 1,
            'nc' => 1,
            'cnonce' => 1,
            'qop' => 1,
            'username' => 1,
            'uri' => 1,
            'response' => 1);
        
        $data = array();
        $keys = implode('|', array_keys($needed));
    
        preg_match_all(
            '@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@',
            $string,
            $matches,
            PREG_SET_ORDER
        );
    
        foreach ($matches as $match) {
            $data[$match[1]] = $match[3] ? $match[3] : $match[4];
            unset($needed[$match[1]]);
        }
    
        return $needed ? false : $data;
    }