<commit_before><?php
namespace ProjectRena\Lib;

use Pheal\Core\Config;
use ProjectRena\RenaApp;

/**
 * Class Pheal
 *
 * @package ProjectRena\Lib
 */
class Pheal
{
				/**
				 * @var
				 */
				protected $app;

				/**
					* @param RenaApp $app
					*/
				function __construct(RenaApp $app)
				{
								$this->app = $app;

								Config::getInstance()->http_method = "curl";
								Config::getInstance()->http_user_agent = $app->baseConfig->getConfig("userAgent", "site", "API DataGetter from projectRena (<EMAIL>)");
								Config::getInstance()->http_post = false;
								Config::getInstance()->http_keepalive = 10; // 10 seconds keep alive
								Config::getInstance()->http_timeout = 30;
								Config::getInstance()->cache = new \Pheal\Cache\RedisStorage(array(
									"host"       => $app->baseConfig->getConfig("host", "redis", "127.0.0.1"),
									"port"       => $app->baseConfig->getConfig("port", "redis", 6379),
									"persistent" => true,
									"auth"       => null,
									"prefix"     => "Pheal",
								));
								Config::getInstance()->log = new \ProjectRena\Lib\PhealLogger();
								Config::getInstance()->api_customkeys = true;
								Config::getInstance()->api_base = $app->baseConfig->getConfig("apiServer", "ccp", "https://api.eveonline.com/");
				}

				/**
				 *
				 */
				function RunAsNew() {}

				/**
					* @return \Pheal\Pheal
					* @throws \Exception
					*/
				public function Pheal()
				{
								if($this->app->Storage->get("Api904") <= date("Y-m-d H:i:s"))
												return new \Pheal\Pheal();
								else
												throw new \Exception("Error, CCP has 904ed us till " . $this->app->Storage->get("Api904"));
				}

				/**
				 * @param \Exception $exception
				 */
				public function handleApiException($keyID, $characterID, $exception)
				{
								$exceptionCode = $exception->getCode();
								$exceptionMessage = $exception->getMessage();

								switch($exceptionCode)
								{
												case 28: // Timeouts
												case 904: // temp ban from CCPs api server
																$this->app->Storage->set("Api904", date("Y-m-d H:i:s", time() + 300));
												break;

												case 403:
												case 502:
												case 503: // Service Unavailable - try again later

												break;

												case 119: // Kills exhausted: retry after [{0}]<commit_msg>Maybe if i added the apikey to the pheal init, it would work as expected<commit_after><?php
namespace ProjectRena\Lib;

use Pheal\Core\Config;
use ProjectRena\RenaApp;

/**
 * Class Pheal
 *
 * @package ProjectRena\Lib
 */
class Pheal
{
				/**
				 * @var
				 */
				protected $app;

				/**
					* @param RenaApp $app
					*/
				function __construct(RenaApp $app)
				{
								$this->app = $app;

								Config::getInstance()->http_method = "curl";
								Config::getInstance()->http_user_agent = $app->baseConfig->getConfig("userAgent", "site", "API DataGetter from projectRena (<EMAIL>)");
								Config::getInstance()->http_post = false;
								Config::getInstance()->http_keepalive = 10; // 10 seconds keep alive
								Config::getInstance()->http_timeout = 30;
								Config::getInstance()->cache = new \Pheal\Cache\RedisStorage(array(
									"host"       => $app->baseConfig->getConfig("host", "redis", "127.0.0.1"),
									"port"       => $app->baseConfig->getConfig("port", "redis", 6379),
									"persistent" => true,
									"auth"       => null,
									"prefix"     => "Pheal",
								));
								Config::getInstance()->log = new \ProjectRena\Lib\PhealLogger();
								Config::getInstance()->api_customkeys = true;
								Config::getInstance()->api_base = $app->baseConfig->getConfig("apiServer", "ccp", "https://api.eveonline.com/");
				}

				/**
				 *
				 */
				function RunAsNew() {}

				/**
					* @return \Pheal\Pheal
					* @throws \Exception
					*/
				public function Pheal($apiKey = null, $vCode = null)
				{
								if($this->app->Storage->get("Api904") <= date("Y-m-d H:i:s"))
												return new \Pheal\Pheal($apiKey, $vCode);
								else
												throw new \Exception("Error, CCP has 904ed us till " . $this->app->Storage->get("Api904"));
				}

				/**
				 * @param \Exception $exception
				 */
				public function handleApiException($keyID, $characterID, $exception)
				{
								$exceptionCode = $exception->getCode();
								$exceptionMessage = $exception->getMessage();

								switch($exceptionCode)
								{
												case 28: // Timeouts
												case 904: // temp ban from CCPs api server
																$this->app->Storage->set("Api904", date("Y-m-d H:i:s", time() + 300));
												break;

												case 403:
												case 502:
												case 503: // Service Unavailable - try again later

												break;

												case 119: // Kills exhausted: retry after [{0}]
{'fraction_non_alphanumeric': 0.16511290656722602, 'fraction_numerical': 0.02030246529935778, 'mean_word_length': 2.1659016393442623, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 73, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1953650', 'n_tokens_mistral': 2285, 'n_tokens_neox': 1483, 'n_words': 305}