protected function addCredentials(array $headers)
    {

        if (!$this->user || !$this->password) {
            return $headers;
        }

        // Check if credentials are already in headers
        foreach ($headers as $line) {
            if (stripos(trim($line),'authorization: basic') === 0) {
                return $headers;
            }
        }

        $auth = $this->user . ':' . $this->password;

        $headers[] = 'Authorization: Basic ' . base64_encode("$auth");

        return $headers;

    }
protected function addCredentials(array $headers)
    {

        if (!$this->user || !$this->password) {
            return $headers;
        }

        // Check if credentials are already in headers
        foreach ($headers as $line) {
            if (stripos(trim($line),'authorization: basic') === 0) {
                return $headers;
            }
        }

        $auth = $this->user . ':' . $this->password;

        $headers[] = 'Authorization: Basic ' . base64_encode("$auth");

        return $headers;

    }
protected function addCredentials ( array $ headers ) { if ( ! $ this -> user || ! $ this -> password ) { return $ headers ; } // Check if credentials are already in headers foreach ( $ headers as $ line ) { if ( stripos ( trim ( $ line ) , 'authorization: basic' ) === 0 ) { return $ headers ; } } $ auth = $ this -> user . ':' . $ this -> password ; $ headers [ ] = 'Authorization: Basic ' . base64_encode ( "$auth" ) ; return $ headers ; }
Add the assigned credentials as Basic Auth headers.

@param array $headers

@return array
Add the assigned credentials as Basic Auth headers .