public function updateCorporationKey(ApiCredentials $key, Element $result) { $result_key = $result->toArray(); $character = array_pop($result_key['characters']); $key->setEveCharacterId($character['characterID'])->setType($result_key['type'])->setAccessMask($result_key['accessMask'])->setEveCorporationId($character['corporationID']); return $key; }
/** * returns the Object as associated array * @return array */ public function toArray() { if ($this->rootElement instanceof CanConvertToArray) { return array('currentTime' => $this->request_time, 'cachedUntil' => $this->cached_until, 'result' => $this->rootElement->toArray()); } else { return array(); } }
/** * initializes the PhealResult * * @param \SimpleXMLElement $xml * @throws \Pheal\Exceptions\APIException */ public function __construct($xml) { // switch to UTC $oldtz = date_default_timezone_get(); date_default_timezone_set('UTC'); $this->request_time = (string) $xml->currentTime; $this->cached_until = (string) $xml->cachedUntil; $this->request_time_unixtime = (int) strtotime($xml->currentTime); $this->cached_until_unixtime = (int) strtotime($xml->cachedUntil); // workaround if cachedUntil is missing in API response (request + 1 hour) if (!$this->cached_until) { $this->cached_until_unixtime = $this->request_time_unixtime + 60 * 60; $this->cached_until = date('Y-m-d H:i:s', $this->cached_until_unixtime); } // switch back to normal time date_default_timezone_set($oldtz); // error detection if ($xml->error) { throw new APIException((int) $xml->error["code"], (string) $xml->error, $xml); } $this->rootElement = Element::parseElement($xml->result); }