Njasm\Soundcloud\Request\Request::buildDefaultHeaders PHP Метод

buildDefaultHeaders() защищенный Метод

protected buildDefaultHeaders ( )
    protected function buildDefaultHeaders()
    {
        $headers = array('Accept: ' . $this->responseFormat);
        $data = $this->resource->getParams();
        if (isset($data['oauth_token'])) {
            $oauth = $data['oauth_token'];
            array_push($headers, 'Authorization: OAuth ' . $oauth);
        }
        // set default content-type if non-existent
        $found = false;
        array_map(function ($value) use(&$found) {
            if (stripos($value, 'content-type') !== false) {
                $found = true;
            }
        }, $this->options[CURLOPT_HTTPHEADER]);
        if (!$found) {
            array_push($this->options[CURLOPT_HTTPHEADER], "Content-Type: application/json");
        }
        //merge headers
        $this->options[CURLOPT_HTTPHEADER] = array_merge($this->options[CURLOPT_HTTPHEADER], $headers);
    }