public function withBasicAuth(?string $username = null, string $password = null): self
    {
        if ($username === null) {
            return $this->withoutHeader('Authorization');
        } else {
            $auth = base64_encode($username . ':' . $password);

            return $this->withHeader('Authorization', "Basic {$auth}");
        }
    }
public function withBasicAuth(?string $username = null, string $password = null): self
    {
        if ($username === null) {
            return $this->withoutHeader('Authorization');
        } else {
            $auth = base64_encode($username . ':' . $password);

            return $this->withHeader('Authorization', "Basic {$auth}");
        }
    }
public function withBasicAuth ( ? string $ username = null , string $ password = null ) : self { if ( $ username === null ) { return $ this -> withoutHeader ( 'Authorization' ) ; } else { $ auth = base64_encode ( $ username . ':' . $ password ) ; return $ this -> withHeader ( 'Authorization' , "Basic {$auth}" ) ; } }
Add basic authorization header

@param string $username
@param string $password
@return $this
Add basic authorization header