<commit_before><?php
/**
 * Apis DataSource
 * 
 * [Short Description]
 *
 * @package default
 * @author <NAME>
 **/
class ApisSource extends DataSource {

/**
 * The description of this data source
 *
 * @var string
 */
	public $description = 'Apis DataSource';

/**
 * Holds the datasource configuration
 *
 * @var array
 */
	public $config = array();
	
	// TODO: Relocate to a dedicated schema file
	public $_schema = array();

/**
 * Instance of CakePHP core HttpSocket class
 *
 * @var HttpSocket
 */
	public $Http = null;

/**
 * Request Logs
 *
 * @var array
 * @access private
 */
	private $__requestLog = array();
	
/**
 * Request Log limit per entry in bytes
 *
 * @var integer
 * @access protected
 */
	protected $_logLimitBytes = 5000;

/**
 * Holds a configuration map
 *
 * @var array
 */
	public $map = array();
	
/**
 * API options
 * @var array
 */
	public $options = array(
		'format'    => 'json',
		'ps'		=> '&', // param separator
		'kvs'		=> '=', // key-value separator
	);

/**
 * Loads HttpSocket class
 *
 * @param array $config
 * @param HttpSocket $Http
 */
	public function __construct($config, $Http = null) {
		parent::__construct($config);

		// Store the API configuration map
		$name = pluginSplit($config['driver']);
		if (Configure::load($name[0] . '.' . Inflector::underscore($name[1]))) {
			$this->map = Configure::read('Apis.' . $name[1]);
		}
		
		// Store the HttpSocket reference
		if (!$Http) {
			if (isset($config['method']) && ($config['method'] = 'OAuth' || !empty($this->map['oauth']['version']))) {
				App::import('Core', 'HttpSocketOauth.HttpSocketOauth');
				$Http = new HttpSocketOauth();
			} else {
				App::import('Core', 'HttpSocket');
				$Http = new HttpSocket();
			}
		}
		$this->Http = $Http;
	}
	
/**
 * Sends HttpSocket requests. Builds your uri and formats the response too.
 *
 * @param string $params
 * @param array $options
 *		method: get, post, delete, put
 *		data: either in string form: "option1=foo&option2=bar" or as a keyed array: array('option1' => 'foo', 'option2' => 'bar')
 * @return array $response
 * @author <NAME>
 */
	public function request(&$model) {
		
		if (is_object($model)) {
			$request = $model->request;
		} elseif (is_array($model)) {
			$request = $model;
		} elseif (is_string($model)) {
			$request = array('uri' => $model);
		}
<commit_msg>Fixed typo with app import<commit_after><?php
/**
 * Apis DataSource
 * 
 * [Short Description]
 *
 * @package default
 * @author <NAME>
 **/
class ApisSource extends DataSource {

/**
 * The description of this data source
 *
 * @var string
 */
	public $description = 'Apis DataSource';

/**
 * Holds the datasource configuration
 *
 * @var array
 */
	public $config = array();
	
	// TODO: Relocate to a dedicated schema file
	public $_schema = array();

/**
 * Instance of CakePHP core HttpSocket class
 *
 * @var HttpSocket
 */
	public $Http = null;

/**
 * Request Logs
 *
 * @var array
 * @access private
 */
	private $__requestLog = array();
	
/**
 * Request Log limit per entry in bytes
 *
 * @var integer
 * @access protected
 */
	protected $_logLimitBytes = 5000;

/**
 * Holds a configuration map
 *
 * @var array
 */
	public $map = array();
	
/**
 * API options
 * @var array
 */
	public $options = array(
		'format'    => 'json',
		'ps'		=> '&', // param separator
		'kvs'		=> '=', // key-value separator
	);

/**
 * Loads HttpSocket class
 *
 * @param array $config
 * @param HttpSocket $Http
 */
	public function __construct($config, $Http = null) {
		parent::__construct($config);

		// Store the API configuration map
		$name = pluginSplit($config['driver']);
		if (Configure::load($name[0] . '.' . Inflector::underscore($name[1]))) {
			$this->map = Configure::read('Apis.' . $name[1]);
		}
		
		// Store the HttpSocket reference
		if (!$Http) {
			if (isset($config['method']) && ($config['method'] = 'OAuth' || !empty($this->map['oauth']['version']))) {
				App::import('Lib', 'HttpSocketOauth.HttpSocketOauth');
				$Http = new HttpSocketOauth();
			} else {
				App::import('Core', 'HttpSocket');
				$Http = new HttpSocket();
			}
		}
		$this->Http = $Http;
	}
	
/**
 * Sends HttpSocket requests. Builds your uri and formats the response too.
 *
 * @param string $params
 * @param array $options
 *		method: get, post, delete, put
 *		data: either in string form: "option1=foo&option2=bar" or as a keyed array: array('option1' => 'foo', 'option2' => 'bar')
 * @return array $response
 * @author <NAME>
 */
	public function request(&$model) {
		
		if (is_object($model)) {
			$request = $model->request;
		} elseif (is_array($model)) {
			$request = $model;
		} elseif (is_string($model)) {
			$request = array('uri' => $model);
		}

{'fraction_non_alphanumeric': 0.17802385008517888, 'fraction_numerical': 0.004684838160136286, 'mean_word_length': 3.393826005612722, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, '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': '2251172', 'n_tokens_mistral': 1668, 'n_tokens_neox': 1551, 'n_words': 428}