getCurlInfo() public method

public getCurlInfo ( $option = null ) : array
return array
Example #1
0
 /**
  * Returns a cURL option from a Response.
  *
  * @param  Response $response Response to get cURL option from.
  * @param  integer $option cURL option to get.
  *
  * @throws \BadMethodCallException
  * @return mixed Value of the cURL option.
  */
 public static function getCurlOptionFromResponse(Response $response, $option = 0)
 {
     switch ($option) {
         case 0:
             // 0 == array of all curl options
             $info = array();
             foreach (self::$curlInfoList as $option => $key) {
                 $info[$key] = $response->getCurlInfo($key);
             }
             break;
         case CURLINFO_HTTP_CODE:
             $info = $response->getStatusCode();
             break;
         case CURLINFO_SIZE_DOWNLOAD:
             $info = $response->getHeader('Content-Length');
             break;
         case CURLINFO_HEADER_SIZE:
             $info = mb_strlen(HttpUtil::formatAsStatusWithHeadersString($response), 'ISO-8859-1');
             break;
         default:
             $info = $response->getCurlInfo($option);
             break;
     }
     if (!is_null($info)) {
         return $info;
     }
     $constants = get_defined_constants(true);
     $constantNames = array_flip($constants['curl']);
     throw new \BadMethodCallException("Not implemented: {$constantNames[$option]} ({$option}) ");
 }