<commit_before><?php
/*
 * Copyright © 2015 <NAME>
 * 
 * This file is part of OGetIt.
 * 
 * OGetIt is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * OGetIt is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with OGetIt.  If not, see <http://www.gnu.org/licenses/>.
 */
namespace OGetIt;

use OGetIt\Http\OGetIt_HttpRequest;
use OGetIt\CombatReport\OGetIt_CombatReport;
use OGetIt\HarvestReport\OGetIt_HarvestReport;
use OGetIt\SpyReport\OGetIt_SpyReport;

class OGetIt { 
	
	/**
	 * @var integer
	 */
	private $_universeID;
	
	/**
	 * @var string
	 */
	private $_community;
	
	/**
	 * @var string
	 * 
	 */
	private $_apikey;
	
	/**
	 * @var string
	 */
	private $_version;
	
	/**
	 * @var boolean
	 */
	private $_https = false;
	
	/**
	 * @param integer $universeID
	 * @param string $community
	 * @param string $version (optional)
	 */
	public function __construct($universeID, $community, $apikey, $version = 'v1') {
		
		$this->_universeID 	= $universeID;
		$this->_community 	= $community;
		$this->_apikey 		= $apikey;
		$this->_version 	= $version;
		
	}
	
	/**
	 * Use https to connect to the API
	 */
	public function useHttps() {
		
		$this->_https = true;
		
	}
	
	/**
	 * @param string $cr_api_key
	 */
	public function getCombatReport($cr_api_key, $username = false, $password = false) {
		
		$url = OGetIt_Api::constructUrl(OGetIt_Api::TYPE_COMBATREPORT, $this, array(
			'api_key' => $this->_apikey,
			'cr_id' => $cr_api_key
		));
		
		$data = OGetIt_Api::getData($url, $username, $password);
				
		return $data === false ? $data : OGetIt_CombatReport::createCombatReport($data);
		
	}
	
	/**
	 * @param string $rr_api_key
	 */
	public function getHarvestReport($rr_api_key, $username = false, $password = false) {
		
		$url = OGetIt_Api::constructUrl(OGetIt_Api::TYPE_HARVESTREPORT, $this, array(
				'api_key' => $this->_apikey,
				'rr_id' => $rr_api_key
		));
		
		$data = OGetIt_Api::getData($url, $username, $password);
		
		return $data === false ? $data : OGetIt_HarvestReport::createHarvestReport($data);
		
	}
	
	/**
	 * @param string $sr_api_key
	 */
	public function getSpyReport($sr_api_key, $username = false, $password = false) {
		
		$url = OGetIt_Api::constructUrl(OGetIt_Api::TYPE_SPYREPORT, $this, array(
				'api_key' => $this->_apikey,
				'sr_id' => $sr_api_key
		));
		
		$data = OGetIt_Api::getData($url, $username, $password);
		
		return $data === false ? $data : OGetIt_SpyReport::createSpyReport($data);
		
	}
	
	/**
	 * @return integer
	 */
	public function getUniverseID() {
		
		return $this->_universeID;
		
	}
	
	/**
	 * @return string
	 */
	public function getCommunity() {
		
		return $this->_community;
		<commit_msg>General function to get api data<commit_after><?php
/*
 * Copyright © 2015 <NAME>
 * 
 * This file is part of OGetIt.
 * 
 * OGetIt is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * OGetIt is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with OGetIt.  If not, see <http://www.gnu.org/licenses/>.
 */
namespace OGetIt;

use OGetIt\Http\OGetIt_HttpRequest;
use OGetIt\CombatReport\OGetIt_CombatReport;
use OGetIt\HarvestReport\OGetIt_HarvestReport;
use OGetIt\SpyReport\OGetIt_SpyReport;

class OGetIt { 
	
	/**
	 * @var integer
	 */
	private $_universeID;
	
	/**
	 * @var string
	 */
	private $_community;
	
	/**
	 * @var string
	 * 
	 */
	private $_apikey;
	
	/**
	 * @var string
	 */
	private $_version;
	
	/**
	 * @var boolean
	 */
	private $_https = false;
	
	/**
	 * @param integer $universeID
	 * @param string $community
	 * @param string $version (optional)
	 */
	public function __construct($universeID, $community, $apikey, $version = 'v1') {
		
		$this->_universeID 	= $universeID;
		$this->_community 	= $community;
		$this->_apikey 		= $apikey;
		$this->_version 	= $version;
		
	}
	
	/**
	 * Use https to connect to the API
	 */
	public function useHttps() {
		
		$this->_https = true;
		
	}
	
	private function getApiData($type, $label, $key, $username = false, $password = false) {
		
		$url = OGetIt_Api::constructUrl($type, $this, array(
			'api_key' => $this->_apikey,
			$label => $key
		));
		
		return OGetIt_Api::getData($url, $username, $password); 
		
	}
	
	/**
	 * @param string $cr_api_key
	 */
	public function getCombatReport($cr_api_key, $username = false, $password = false) {
		
		$data = $this->getApiData(OGetIt_Api::TYPE_COMBATREPORT, 'cr_id', $cr_api_key, $username, $password);
				
		return $data === false ? $data : OGetIt_CombatReport::createCombatReport($data);
		
	}
	
	/**
	 * @param string $rr_api_key
	 */
	public function getHarvestReport($rr_api_key, $username = false, $password = false) {
		
		$data = $this->getApiData(OGetIt_Api::TYPE_HARVESTREPORT, 'rr_id', $rr_api_key, $username, $password);
		
		return $data === false ? $data : OGetIt_HarvestReport::createHarvestReport($data);
		
	}
	
	/**
	 * @param string $sr_api_key
	 */
	public function getSpyReport($sr_api_key, $username = false, $password = false) {
		
		$data = $this->getApiData(OGetIt_Api::TYPE_SPYREPORT, 'sr_id', $sr_api_key, $username, $password);
				
		return $data === false ? $data : OGetIt_SpyReport::createSpyReport($data);
		
	}
	
	/**
	 * @return integer
	 */
	public function getUniverseID() {
		
		return $this->_universeID;
		
	}
	
	/**
	 * @return string
	 */
	public function getCommunity() {
		
		return $this->_community;
		
{'fraction_non_alphanumeric': 0.13335455124124762, 'fraction_numerical': 0.0019096117122851686, 'mean_word_length': 3.5118449389806172, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3466601', 'n_tokens_mistral': 2379, 'n_tokens_neox': 2080, 'n_words': 558}