private function getHeader(): ?string
    {
        if ('Digest' == $this->getAuthenticationMethod()) {
            $username = $this->getUsername();
            $realm = $this->getRealm();
            $nonce = $this->getNonce();
            $response = $this->getResponse();
            if (($username) && ($realm) && ($nonce) && ($response)) {
                $uri = $this->getUri();
                $opaque = $this->getOpaque();
                $qop = $this->getQOP();

                $header = 'Digest';
                $header .= ' username="'.$username.'",';
                $header .= ' realm="'.$realm.'",';
                $header .= ' nonce="'.$nonce.'",';
                $header .= ' response="'.$response.'",';

                if ($uri) {
                    $header .= ' uri="'.$uri.'",';
                }
                if ($opaque) {
                    $header .= ' opaque="'.$opaque.'",';
                }

                if ($qop) {
                    $header .= ' qop='.$qop.',';

                    $cnonce = $this->getClientNonce();
                    $nc = $this->getNonceCount();

                    if ($cnonce) {
                        $header .= ' nc='.$nc.',';
                    }
                    if ($cnonce) {
                        $header .= ' cnonce="'.$cnonce.'",';
                    }
                }

                // Remove the last comma from the header
                $header = substr($header, 0, \strlen($header) - 1);
                // Discard the Client Nonce if OPTION_DISCARD_CLIENT_NONCE is set.
                if ($this->options & self::OPTION_DISCARD_CLIENT_NONCE) {
                    $this->discardClientNonce();
                }

                return $header;
            }
        }
        if ('Basic' == $this->getAuthenticationMethod()) {
            $username = $this->getUsername();
            $password = $this->getPassword();
            if (($username) && ($password)) {
                $header = 'Basic '.base64_encode("{$username}:{$password}");

                return $header;
            }
        }

        return null;
    }
private function getHeader(): ?string
    {
        if ('Digest' == $this->getAuthenticationMethod()) {
            $username = $this->getUsername();
            $realm = $this->getRealm();
            $nonce = $this->getNonce();
            $response = $this->getResponse();
            if (($username) && ($realm) && ($nonce) && ($response)) {
                $uri = $this->getUri();
                $opaque = $this->getOpaque();
                $qop = $this->getQOP();

                $header = 'Digest';
                $header .= ' username="'.$username.'",';
                $header .= ' realm="'.$realm.'",';
                $header .= ' nonce="'.$nonce.'",';
                $header .= ' response="'.$response.'",';

                if ($uri) {
                    $header .= ' uri="'.$uri.'",';
                }
                if ($opaque) {
                    $header .= ' opaque="'.$opaque.'",';
                }

                if ($qop) {
                    $header .= ' qop='.$qop.',';

                    $cnonce = $this->getClientNonce();
                    $nc = $this->getNonceCount();

                    if ($cnonce) {
                        $header .= ' nc='.$nc.',';
                    }
                    if ($cnonce) {
                        $header .= ' cnonce="'.$cnonce.'",';
                    }
                }

                // Remove the last comma from the header
                $header = substr($header, 0, \strlen($header) - 1);
                // Discard the Client Nonce if OPTION_DISCARD_CLIENT_NONCE is set.
                if ($this->options & self::OPTION_DISCARD_CLIENT_NONCE) {
                    $this->discardClientNonce();
                }

                return $header;
            }
        }
        if ('Basic' == $this->getAuthenticationMethod()) {
            $username = $this->getUsername();
            $password = $this->getPassword();
            if (($username) && ($password)) {
                $header = 'Basic '.base64_encode("{$username}:{$password}");

                return $header;
            }
        }

        return null;
    }
private function getHeader ( ) : ? string { if ( 'Digest' == $ this -> getAuthenticationMethod ( ) ) { $ username = $ this -> getUsername ( ) ; $ realm = $ this -> getRealm ( ) ; $ nonce = $ this -> getNonce ( ) ; $ response = $ this -> getResponse ( ) ; if ( ( $ username ) && ( $ realm ) && ( $ nonce ) && ( $ response ) ) { $ uri = $ this -> getUri ( ) ; $ opaque = $ this -> getOpaque ( ) ; $ qop = $ this -> getQOP ( ) ; $ header = 'Digest' ; $ header .= ' username="' . $ username . '",' ; $ header .= ' realm="' . $ realm . '",' ; $ header .= ' nonce="' . $ nonce . '",' ; $ header .= ' response="' . $ response . '",' ; if ( $ uri ) { $ header .= ' uri="' . $ uri . '",' ; } if ( $ opaque ) { $ header .= ' opaque="' . $ opaque . '",' ; } if ( $ qop ) { $ header .= ' qop=' . $ qop . ',' ; $ cnonce = $ this -> getClientNonce ( ) ; $ nc = $ this -> getNonceCount ( ) ; if ( $ cnonce ) { $ header .= ' nc=' . $ nc . ',' ; } if ( $ cnonce ) { $ header .= ' cnonce="' . $ cnonce . '",' ; } } // Remove the last comma from the header $ header = substr ( $ header , 0 , \ strlen ( $ header ) - 1 ) ; // Discard the Client Nonce if OPTION_DISCARD_CLIENT_NONCE is set. if ( $ this -> options & self :: OPTION_DISCARD_CLIENT_NONCE ) { $ this -> discardClientNonce ( ) ; } return $ header ; } } if ( 'Basic' == $ this -> getAuthenticationMethod ( ) ) { $ username = $ this -> getUsername ( ) ; $ password = $ this -> getPassword ( ) ; if ( ( $ username ) && ( $ password ) ) { $ header = 'Basic ' . base64_encode ( "{$username}:{$password}" ) ; return $ header ; } } return null ; }
Returns the full Authentication header for use in authenticating the client with either Digest or Basic authentication.

@return string the Authentication header to be sent to the server
Returns the full Authentication header for use in authenticating the client with either Digest or Basic authentication .