Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Elophant
- {
- /**
- * API Host
- *
- * @var string
- * @access private
- **/
- private $_api_url = 'http://api.elophant.com/v2/';
- /**
- * LOL Region
- *
- * @var string
- * @access private
- **/
- private $_lol_region = 'na';
- /**
- * The Api Key
- *
- * @var string
- * @access private
- **/
- private $_api_key = '';
- /**
- * Constructor
- *
- * @access public
- * @return void
- */
- public function __construct ()
- {}
- /**
- * getChampions
- *
- * @access public
- * @return array
- */
- public function getChampions()
- {
- return $this->_apiCall('champions');
- }
- /**
- * getItems
- *
- * @access public
- * @return array
- */
- public function getItems()
- {
- return $this->_apiCall('items');
- }
- /**
- * getStatus
- *
- * @access public
- * @return array
- */
- public function getStatus()
- {
- return $this->_apiCall('status');
- }
- /**
- * getSummonerByName
- *
- * @access public
- * @return array
- */
- public function getSummonerByName($summoner_name)
- {
- $summoner_name = str_replace(' ', '%20', urlencode($summoner_name));
- return $this->_apiCall($this->getLolRegion().'/summoner/'.$summoner_name);
- }
- /**
- * getInProgressGameInfo
- *
- * @access public
- * @return array
- */
- public function getInProgressGameInfo($summoner_name)
- {
- return $this->_apiCall($this->getLolRegion().'/in_progress_game_info/'.$summoner_name);
- }
- /**
- * getSummonerTeamInfo
- *
- * @access public
- * @param int $summoner_id
- * @return array
- */
- public function getSummonerTeamInfo($summoner_id)
- {
- return $this->_apiCall($this->getLolRegion().'/summoner_team_info/'.$summoner_id);
- }
- /**
- * getMasteryPages
- *
- * @access public
- * @param int $summoner_id
- * @return array
- */
- public function getMasteryPages($summoner_id)
- {
- return $this->_apiCall($this->getLolRegion().'/mastery_pages/'.$summoner_id);
- }
- /**
- * getRunePages
- *
- * @access public
- * @param int $summoner_id
- * @return array
- */
- public function getRunePages($summoner_id)
- {
- return $this->_apiCall($this->getLolRegion().'/rune_pages/'.$summoner_id);
- }
- /**
- * getRecentGames
- *
- * @access public
- * @param int $account_id
- * @return array
- */
- public function getRecentGames($account_id)
- {
- return $this->_apiCall($this->getLolRegion().'/recent_games/'.$account_id);
- }
- /**
- * getSummonerNames
- *
- * @access public
- * @param array $account_ids
- * @return array
- */
- public function getSummonerNames($account_ids)
- {
- return $this->_apiCall($this->getLolRegion().'/summoner_names/'.implode(',', $account_ids));
- }
- /**
- * getPlayerStats
- *
- * @access public
- * @return array
- */
- public function getPlayerStats($account_id, $season = 'CURRENT')
- {
- return $this->_apiCall($this->getLolRegion().'/player_stats/'.$account_id.'/'.$season);
- }
- /**
- * getRankedStats
- *
- * @access public
- * @return array
- */
- public function getRankedStats($account_id, $season = 'CURRENT')
- {
- return $this->_apiCall($this->getLolRegion().'/ranked_stats/'.$account_id.'/'.$season);
- }
- /**
- * getTeamById
- *
- * @access public
- * @return array
- */
- public function getTeamById($team_id)
- {
- return $this->_apiCall($this->getLolRegion().'/team/'.$team_id);
- }
- /**
- * getTeamByTagOrName
- *
- * @access public
- * @return array
- */
- public function getTeamByTagOrName($tag_or_name)
- {
- return $this->_apiCall($this->getLolRegion().'/find_team/'.$tag_or_name);
- }
- /**
- * getTeamRankedStats
- *
- * @access public
- * @return array
- */
- public function getTeamRankedStats($team_id)
- {
- return $this->_apiCall($this->getLolRegion().'/team/'.$team_id.'/ranked_stats');
- }
- /**
- * setApiUrl
- *
- * @access public
- * @param string $url
- * @return void
- */
- public function setApiUrl($url)
- {
- $this->_api_url = $url;
- }
- /**
- * getApiUrl
- *
- * @access public
- * @return string
- */
- public function getApiUrl()
- {
- return $this->_api_url;
- }
- /**
- * getApiKey
- *
- * @access public
- * @return string
- */
- public function getApiKey()
- {
- return $this->_api_key;
- }
- /**
- * setApiKey
- *
- * @access public
- * @param string $api_key
- * @return void
- */
- public function setApiKey($api_key)
- {
- $this->_api_key = $api_key;
- }
- /**
- * getLolRegion
- *
- * @access public
- * @return string
- */
- public function getLolRegion()
- {
- return $this->_lol_region;
- }
- /**
- * setLolRegion
- *
- * @access public
- * @param string $region
- * @return void
- */
- public function setLolRegion($region= 'na')
- {
- $this->_lol_region = $region;
- }
- /**
- * _apiCall
- *
- * @access private
- * @access string $path
- * @param array $get_args
- * @return mixed
- */
- private function _apiCall($path)
- {
- $get_string = '?key='.rawurlencode($this->getApiKey());
- $response = @file_get_contents($this->getApiUrl().$path.$get_string);
- $data = json_decode($response, true);
- if ($data && is_array($data))
- {
- if (isset($data['success']) && $data['success'] == false && isset($data['error']))
- {
- error_log('Elophant API Error: '.$data['error']);
- }
- else
- return $data;
- }
- else
- return $response;
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement