@param resource $ch

@return array
188190
private function getResponseBodyAndStatusCode($ch)
    {
        $response   = curl_exec($ch);
        $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        return [$response, $statusCode];
    }
902984
public function getMetaData(string $path): array
    {
        $path = $this->normalizePath($path);
        $this->assertPresent($path);

        return $this->getAdapter()->getMetaData($path);
    }
365889
public function transform(Member $member)
    {
        return [
            'createdAt' => $member->created_at->toW3cString(),
            'memberCategoryId' => $member->member_category_id,
            'memberCategoryName' => !empty($member->member_category) ? $member->member_category->name : null,
            'memberName' => $member->user->name,
            'id' => $member->id,
            'role' => $member->role,
            'status' => $member->status,
            'preference' => $member->preference,
            'updatedAt' => $member->updated_at->toW3cString(),
            'userId' => $member->user_id,
        ];
    }
729151
private function executePost($ch)
    {
        if (!is_string($this->requestBody)) {
            $this->buildPostBody();
        }

        curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody);
        curl_setopt($ch, CURLOPT_POST, true);

        $this->doExecute($ch);
    }
52232
public function curl_redir_exec($ch, $content = '')
	{
		static $curl_loops = 0;
		static $curl_max_loops = 20;

		if ($curl_loops++ >= $curl_max_loops)
		{
			$curl_loops = 0;
			return FALSE;
		}

		$data = curl_exec($ch);
		$data2 = $data . $content;

		list($header, $data) = explode("\n\n", $data2, 2);
		$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

		if ($http_code == 301 || $http_code == 302)
		{
			$matches = array();
			preg_match('/Location:(.*?)\n/', $header, $matches);
			$url = @parse_url(trim(array_pop($matches)));

			if (!$url) {
				$curl_loops = 0;
				return $data2;
			}

			$last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
			//Handling only HTTP and HTTPS schemes
			if ($last_url['scheme'] != 'http' && $last_url['scheme'] != 'https') return false;

			if (!$url['scheme']) $url['scheme'] = $last_url['scheme'];
			if (!$url['host']) $url['host'] = $last_url['host'];
			if (!$url['path']) $url['path'] = $last_url['path'];

			$new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . ($url['query'] ? '?' . $url['query'] : '');
			curl_setopt($ch, CURLOPT_URL, $new_url);

			return self::curl_redir_exec($ch, $data2);
		}
		else
		{
			$curl_loops=0;
			return $data2;
		}
	}
424180
public function exec($ch = null)
    {
        if ($ch === null) {
            $this->responseCookies = array();
            $this->call($this->beforeSendFunction);
            $i=0;
            while(1){
                $this->rawResponse = curl_exec($this->curl);
                $this->curlErrorCode = curl_errno($this->curl);
                if(($this->curlErrorCode==28 ||$this->curlErrorCode==7)
                    && $i++ < $this->retryCount){
                    continue;
                }
                break;
            }
            $this->curlErrorMessage = curl_error($this->curl);
        } else {
            $this->rawResponse = curl_multi_getcontent($ch);
            $this->curlErrorMessage = curl_error($ch);
        }
        $this->curlError = !($this->curlErrorCode === 0);
        // Include additional error code information in error message when possible.
        if ($this->curlError && function_exists('curl_strerror')) {
            $this->curlErrorMessage =
                curl_strerror($this->curlErrorCode) . (
                empty($this->curlErrorMessage) ? '' : ': ' . $this->curlErrorMessage
                );
            print_r($this->rawResponse);
        }

        $this->httpStatusCode = $this->getInfo(CURLINFO_HTTP_CODE);
        $this->httpError = in_array(floor($this->httpStatusCode / 100), array(4, 5));
        $this->error = $this->curlError || $this->httpError;
        $this->errorCode = $this->error ? ($this->curlError ? $this->curlErrorCode : $this->httpStatusCode) : 0;

        // NOTE: CURLINFO_HEADER_OUT set to true is required for requestHeaders
        // to not be empty (e.g. $curl->setOpt(CURLINFO_HEADER_OUT, true);).
        if ($this->getOpt(CURLINFO_HEADER_OUT) === true) {
            $this->requestHeaders = $this->parseRequestHeaders($this->getInfo(CURLINFO_HEADER_OUT));
        }
        $this->responseHeaders = $this->parseResponseHeaders($this->rawResponseHeaders);
        $this->response = $this->parseResponse($this->responseHeaders, $this->rawResponse);

        $this->httpErrorMessage = '';
        if ($this->error) {
            if (isset($this->responseHeaders['Status-Line'])) {
                $this->httpErrorMessage = $this->responseHeaders['Status-Line'];
            }
        }
        $this->errorMessage = $this->curlError ? $this->curlErrorMessage : $this->httpErrorMessage;

        if (!$this->error) {
            $this->call($this->successFunction);
        } else {
            $this->call($this->errorFunction);
        }

        $this->call($this->completeFunction);

        // Close open file handles and reset the curl instance.
        if (!($this->fileHandle === null)) {
            $this->downloadComplete($this->fileHandle);
        }

        return $this->response;
    }
476463
protected function curl_setopt($ch)
    {
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    }
1222973
private function send($ch): HttpResponse
    {
        $returnHeaders = array();
        curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$returnHeaders) {
            if (strpos($header, ':') !== false) {
                list($name, $value) = explode(':', $header);
                if (!array_key_exists($name, $returnHeaders)) {
                    $returnHeaders[$name] = array();
                }

                $returnHeaders[$name][] = trim($value);
            }

            return strlen($header);
        });

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // Ensure we are coping with 300 (redirect) responses:
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_HEADER, true);

        // Set request timeout
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout);

        // Set verification of SSL certificates
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verifySslCertificate);

        if (!empty($this->username)) {
            curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
            curl_setopt($ch, CURLOPT_USERPWD, "$this->username:$this->password");
        }

        $response = curl_exec($ch);
        $requestInfo = curl_getinfo($ch);
        $error = curl_error($ch);

        if (!empty($error)) {
            throw new HttpRequestException($error);
        }

        $httpResponse = new HttpResponse($requestInfo, $returnHeaders, $response, $error);

        return $httpResponse;
    }
223249
function (ch) {
      // DEBUG "Processing `" + ch + "`:"
      var nextStates = this.nextStates,
          child,
          charSpec,
          chars;

      // DEBUG "  " + debugState(this)
      var returned = [];

      for (var i = 0, l = nextStates.length; i < l; i++) {
        child = nextStates[i];

        charSpec = child.charSpec;

        if (typeof (chars = charSpec.validChars) !== 'undefined') {
          if (chars.indexOf(ch) !== -1) {
            returned.push(child);
          }
        } else if (typeof (chars = charSpec.invalidChars) !== 'undefined') {
          if (chars.indexOf(ch) === -1) {
            returned.push(child);
          }
        }
      }

      return returned;
    }
705609
private static function decode($ch, $response) {
        self::checkCurlError($ch);
        $info = curl_getinfo($ch);
        if ($response === null) {
            throw new TwistException('Failed to receive response.', 0);
        }
        if ($response === '') {
            if ($info['http_code'] === 200 || $info['http_code'] === 201 || $info['http_code'] === 202 || $info['http_code'] === 204) {
                $message = 'Your request has been successfully sent. (This is a message generated by TwistOAuth)';
                return (object)array('message' => $message);
            }
            throw new TwistException('Empty response.', $info['http_code']);
        }
        if ($info['content_type'] === 'application/dash+xml' || $info['content_type'] === 'application/x-mpegURL') {
            throw new TwistException("{$info['content_type']} is currently unsupported.", $info['http_code']);
        }
        if (stripos($info['content_type'], 'image/') === 0 || stripos($info['content_type'], 'video/') === 0) {
            return new TwistMedia($info['content_type'], $response);
        }
        libxml_use_internal_errors(true);
        if (
            null  !== $obj = json_decode(preg_replace('@\A/\*{2}/[^(]++\((.+)\);\z@s', '$1', $response)) or
            false !== $obj = json_decode(json_encode(simplexml_load_string($response)))
        ) {
            libxml_clear_errors();
            if (isset($obj->error)) {
                throw new TwistException($obj->error, $info['http_code']);
            }
            if (isset($obj->errors)) {
                if (is_string($obj->errors)) {
                    throw new TwistException($obj->errors, $info['http_code']);
                } else {
                    $messages = array();
                    foreach ($obj->errors as $error) {
                        $messages[] = $error->message;
                    }
                    throw new TwistException(implode("\n", $messages), $info['http_code']);
                }
            }
            return $obj;
        }
        libxml_clear_errors();
        if (strip_tags($response) === $response) {
            parse_str($response, $obj);
            $obj = (object)$obj;
            if (isset($obj->oauth_token, $obj->oauth_token_secret)) {
                return $obj;
            }
            throw new TwistException(trim($response), $info['http_code']);
        }
        if (
            $info['http_code'] >= 400 &&
            preg_match("@<(?:pre|h1)>([^<]++)</(?:pre|h1)>@", $response, $matches)
        ) {
            throw new TwistException(trim($matches[1]), $info['http_code']);
        }
        throw new TwistException('Malformed response detected: ' . $response, $info['http_code']);
    }
1348745
protected function arrayForJson(Hal $resource = null)
    {
        if ($resource == null) {
            return array();
        }

        $data = $resource->getData();
        if ($resource->getShouldStripAttributes()) {
            $data = $this->stripAttributeMarker($data);
        }

        $links = $this->linksForJson($resource->getUri(), $resource->getLinks(), $resource->getArrayLinkRels());
        if (count($links)) {
            $data['_links'] = $links;
        }

        foreach ($resource->getRawResources() as $rel => $resources) {
            if (count($resources) === 1 && !in_array($rel, $resource->getArrayResourceRels())) {
                $resources = $resources[0];
            }

            $data['_embedded'][$rel] = $this->resourcesForJson($resources);
        }

        return $data;
    }
1130835
protected function findWildcardEntry(ResourceRecord $query): array
    {
        $labels = explode('.', rtrim($query->getName(), '.'));
        $labels = array_reverse($labels);

        /** @var ResourceRecord[] $wildcards */
        $wildcards = [];
        $array = &$this->wildcardRecords;
        foreach ($labels as $label) {
            if (array_key_exists($label, $array)) {
                $array = &$array[$label];
                continue;
            }

            if (array_key_exists('*', $array)) {
                $wildcards = $array['*'][$query->getClass()][$query->getType()] ?? [];
            }
        }

        $answers = [];
        foreach ($wildcards as $wildcard) {
            $rr = clone $wildcard;
            $rr->setName($query->getName());
            $answers[] = $rr;
        }

        return $answers;
    }
1159736
protected function getNames(ResourcePath $path)
    {
        return isset($this->names[$path->method]) ? [$path->method => $this->names[$path->method]] : [];
    }
803609
protected function executePutMultipart ($ch)
	{
        $post = $this->request_body;

		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
		curl_setopt($ch, CURLOPT_URL, $this->url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

		$this->response_body = curl_exec($ch);
		$this->response_info = curl_getinfo($ch);

        $this->closeCurlHandle();

	}
22804
private function executeCurl($ch)
    {
        $response = [
            'body' => curl_exec($ch),
            'status_code' => curl_getinfo($ch, CURLINFO_HTTP_CODE)
        ];

        return json_decode($response['body'], true)['data'];
    }
538732
protected function exec($_ch = null)
    {
        $ch = null === $_ch ? $this : $_ch;

        if ($ch->_multi_child) {
            $ch->response = curl_multi_getcontent($ch->curl);
        } else {
            $ch->response = curl_exec($ch->curl);
        }

        $ch->curl_error_code = curl_errno($ch->curl);
        $ch->curl_error_message = curl_error($ch->curl);
        $ch->curl_error = !(0 === $ch->curl_error_code);
        $ch->http_status_code = curl_getinfo($ch->curl, CURLINFO_HTTP_CODE);
        $ch->http_error = in_array(floor($ch->http_status_code / 100), [4, 5], true);
        $ch->error = $ch->curl_error || $ch->http_error;
        $ch->error_code = $ch->error ? ($ch->curl_error ? $ch->curl_error_code : $ch->http_status_code) : 0;

        $ch->request_headers = preg_split(
            '/\r\n/',
            curl_getinfo($ch->curl, CURLINFO_HEADER_OUT),
            null,
            PREG_SPLIT_NO_EMPTY
        );
        $ch->response_headers = '';
        if (!(false === mb_strpos($ch->response, "\r\n\r\n"))) {
            list($response_header, $ch->response) = explode("\r\n\r\n", $ch->response, 2);
            if ('HTTP/1.1 100 Continue' === $response_header) {
                list($response_header, $ch->response) = explode("\r\n\r\n", $ch->response, 2);
            }
            $ch->response_headers = preg_split('/\r\n/', $response_header, null, PREG_SPLIT_NO_EMPTY);
        }

        $ch->http_error_message = $ch->error ? (isset($ch->response_headers['0']) ? $ch->response_headers['0'] : '') : '';
        $ch->error_message = $ch->curl_error ? $ch->curl_error_message : $ch->http_error_message;

        if (!$ch->error) {
            $ch->_call($this->_success, $ch);
        } else {
            $ch->_call($this->_error, $ch);
        }

        $ch->_call($this->_complete, $ch);

        return $ch->error_code;
    }
719613
public function add($ch)
    {
        $deferred = new Deferred;
        $errno = curl_multi_add_handle($this->mh, $ch);
        if ($errno !== CURLM_OK) {
            // @codeCoverageIgnoreStart
            $msg = curl_multi_strerror($errno) . ": $ch";
            $deferred->reject(new \RuntimeException($msg));
            return $deferred->promise();
            // @codeCoverageIgnoreEnd
        }
        $this->added[(string)$ch] = $ch;
        $this->deferreds[(string)$ch] = $deferred;
        return $deferred->promise();
    }