<commit_before><?php

class ChargeBee_Curl
{

  public static function utf8($value)
  {
    if (is_string($value))
      return utf8_encode($value);
    else
      return $value;
  }

	public static function doRequest($meth, $url, $env, $params = array())
	{
		list($response, $httpCode) = self::request($meth, $url, $env, $params);
		$respJson = self::processResponse($response, $httpCode);
		return $respJson;
	}

	public static function request($meth, $url, $env, $params)
	{
		$curl = curl_init();
		$opts = array();
		if ($meth == ChargeBee_Request::GET) 
		{
			$opts[CURLOPT_HTTPGET] = 1;
			if (count($params) > 0) 
			{
				$encoded = http_build_query($params, null, '&');
				$url = "$url?$encoded";
			}
		} 
		else if ($meth == ChargeBee_Request::POST) 
		{
			$opts[CURLOPT_POST] = 1;
			$opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
		} 
		else 
		{
			throw new ChargeBee_APIError("Invalid http method $meth");
		}
		$url = self::utf8($env->apiUrl($url));
		$opts[CURLOPT_URL] = $url;
		$opts[CURLOPT_RETURNTRANSFER] = true;
		$opts[CURLOPT_CONNECTTIMEOUT] = 50;
		$opts[CURLOPT_TIMEOUT] = 100;
		$headers = array(
      'Accept: application/json',
			"User-Agent: Chargebee-PHP-Client");
    $opts[CURLOPT_HTTPHEADER] = $headers;
		$opts[CURLOPT_USERPWD] = $env->getApiKey() . ':';
    if (ChargeBee::getVerifyCaCerts()) 
		{
        $opts[CURLOPT_SSL_VERIFYPEER] = true;
        $opts[CURLOPT_SSL_VERIFYHOST] = 2;
				$opts[CURLOPT_CAINFO] = ChargeBee::getCaCertPath();
    }
		curl_setopt_array($curl, $opts);

		$response = curl_exec($curl);<commit_msg>Sending the library version along the User-Agent header<commit_after><?php

class ChargeBee_Curl
{

  public static function utf8($value)
  {
    if (is_string($value))
      return utf8_encode($value);
    else
      return $value;
  }

	public static function doRequest($meth, $url, $env, $params = array())
	{
		list($response, $httpCode) = self::request($meth, $url, $env, $params);
		$respJson = self::processResponse($response, $httpCode);
		return $respJson;
	}

	public static function request($meth, $url, $env, $params)
	{
		$curl = curl_init();
		$opts = array();
		if ($meth == ChargeBee_Request::GET) 
		{
			$opts[CURLOPT_HTTPGET] = 1;
			if (count($params) > 0) 
			{
				$encoded = http_build_query($params, null, '&');
				$url = "$url?$encoded";
			}
		} 
		else if ($meth == ChargeBee_Request::POST) 
		{
			$opts[CURLOPT_POST] = 1;
			$opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
		} 
		else 
		{
			throw new ChargeBee_APIError("Invalid http method $meth");
		}
		$url = self::utf8($env->apiUrl($url));
		$opts[CURLOPT_URL] = $url;
		$opts[CURLOPT_RETURNTRANSFER] = true;
		$opts[CURLOPT_CONNECTTIMEOUT] = 50;
		$opts[CURLOPT_TIMEOUT] = 100;
		$userAgent = "Chargebee-PHP-Client" . " v" . ChargeBee_Version::VERSION;
		$headers = array(
      'Accept: application/json',
			"User-Agent: " . $userAgent);
    $opts[CURLOPT_HTTPHEADER] = $headers;
		$opts[CURLOPT_USERPWD] = $env->getApiKey() . ':';
    if (ChargeBee::getVerifyCaCerts()) 
		{
        $opts[CURLOPT_SSL_VERIFYPEER] = true;
        $opts[CURLOPT_SSL_VERIFYHOST] = 2;
				$opts[CURLOPT_CAINFO] = ChargeBee::getCaCertPath();
    }
		curl_setopt_array($curl, $opts);

		$response = curl_exec($curl);
{'fraction_non_alphanumeric': 0.16879174256223436, 'fraction_numerical': 0.007285974499089253, 'mean_word_length': 4.007598784194529, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5965797', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1253, 'n_words': 220}