<commit_before><?php

namespace Bamboo\Feeds;

use Guzzle\Http;
use Bamboo\Feeds\ClientFake;

class Client
{

    private $_baseUrl = "http://d.bbc.co.uk/";
    private $_version = "ibl/v1/";
    private $_config = array();
    private $_httpClient;
    private $_defaultParams = array(
                                "api_key" => "",
                                "availability" => "all",
                                "lang" => "en",
                                "rights" => "web"
            );

    public static $instance;

    public static function getInstance() {
        if (!self::$instance) {
            self::$instance = new self();
        }

        return self::$instance;
    }

    public function setHttpClient($httpClient) {
        $this->_httpClient = $httpClient;
    }

    public function setConfig($config) {
        $this->_config = $config;
    }

    public function request($feed, $params = array()) {
        $client = $this->_getClient();
        $params = array_merge($this->_defaultParams, $this->_config, $params);

        try {
          $request = $client->get(
              $this->_version . $feed . ".json", 
              array(), 
              array(
                'query' => $params,
                //'proxy' =>  'tcp://www-cache.reith.bbc.co.uk:80',
              )
          );
        } catch (RequestException $e) {
            die($e->getMessage());
        }
//var_dump($request->getUrl());die;
        $response = $request->send();
        $object = $this->_parseResponse($response);

        return $object;
    }

    private function _parseResponse($response) {
        $array = $response->json();
        $json = json_encode($array);<commit_msg>include a setProxy method<commit_after><?php

namespace Bamboo\Feeds;

use Guzzle\Http;
use Bamboo\Feeds\ClientFake;

class Client
{

    private $_baseUrl = "http://d.bbc.co.uk/";
    private $_version = "ibl/v1/";
    private $_proxy = "";
    private $_config = array();
    private $_httpClient;
    private $_defaultParams = array(
                                "api_key" => "",
                                "availability" => "all",
                                "lang" => "en",
                                "rights" => "web"
            );

    public static $instance;

    public static function getInstance() {
        if (!self::$instance) {
            self::$instance = new self();
        }

        return self::$instance;
    }

    public function setHttpClient($httpClient) {
        $this->_httpClient = $httpClient;
    }

    public function setConfig($config) {
        $this->_config = $config;
    }

    public function setProxy($proxy) {
        $this->_proxy = $proxy;
    }

    public function request($feed, $params = array()) {
        $client = $this->_getClient();
        $params = array_merge($this->_defaultParams, $this->_config, $params);

        try {
          $request = $client->get(
              $this->_version . $feed . ".json", 
              array(), 
              array(
                'query' => $params,
                'proxy' =>  $this->_proxy,
              )
          );
        } catch (RequestException $e) {
            //$request->getUrl()
            die($e->getMessage());
        }
 
        $response = $request->send();
        $object = $this->_parseResponse($response);

        return $object;
    }

    private function _parseResponse($response) {
        $array = $response->json();
        $json = json_encode($array);
{'fraction_non_alphanumeric': 0.1485486624928856, 'fraction_numerical': 0.0011383039271485487, 'mean_word_length': 1.6428571428571428, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '4411455', 'n_tokens_mistral': 994, 'n_tokens_neox': 953, 'n_words': 199}