/** * @param $url_mixed * @param array $data * @return int|mixed|null * @throws \ErrorException */ public function get($url_mixed, $data = []) { if (is_array($url_mixed)) { $curl_multi = curl_multi_init(); $this->_multi_parent = true; $this->curls = []; foreach ($url_mixed as $url) { $curl = new self(); $curl->_multi_child = true; $curl->setOpt(CURLOPT_URL, $this->_buildURL($url, $data), $curl->curl); $curl->setOpt(CURLOPT_HTTPGET, true); $this->_call($this->_before_send, $curl); $this->curls[] = $curl; $curlm_error_code = curl_multi_add_handle($curl_multi, $curl->curl); if (!($curlm_error_code === CURLM_OK)) { throw new \ErrorException('cURL multi add handle error: ' . curl_multi_strerror($curlm_error_code)); } } foreach ($this->curls as $ch) { foreach ($this->_options as $key => $value) { $ch->setOpt($key, $value); } } do { $status = curl_multi_exec($curl_multi, $active); } while ($status === CURLM_CALL_MULTI_PERFORM || $active); foreach ($this->curls as $ch) { $this->exec($ch); } } else { $this->setopt(CURLOPT_URL, $this->_buildURL($url_mixed, $data)); $this->setopt(CURLOPT_HTTPGET, true); return $this->exec(); } return null; }