/** * ensure there is an ID placed * @param string $id * @param string $charname * @return int * @throws \Exception */ public function ensureEveEntityID($id, $charname) { $id = (int) $id; if ($id == 0) { if ($id = NameSearch::getEveIdByName($charname)) { return $id; } if (!empty($charname)) { Registry::getInstance()->getLogger()->debug("{$charname} not found, trying to fetch from API"); $pheal = new Pheal(); $result = $pheal->eveScope->typeName(array('names' => $charname))->toArray(); if ((int) $result[0]['characterID'] > 0) { return (int) $result[0]['characterID']; } } Registry::getInstance()->getLogger()->warning("no id found for {$charname}"); // with an empty charname we have to assume its 0 return 0; //throw new \Exception("No such characterID"); } return $id; }