/** * Parse a new Addon from a SimpleXMLElement. * * @param $list_game (Object) SimpleXMLElement node to be "parsed". * @return (object) Resultant Addon object. */ private static function parseAddon(&$list_addon) { if (!$list_addon instanceof SimpleXMLElement) { throw new Exception('Received invalid list_addon'); } $title = clean_text($list_addon->title); $version = !empty($list_addon->version) ? clean_text($list_addon->version) : NULL; $downloadUri = !empty($list_addon->downloadUri) ? safe_url($list_addon->downloadUri) : NULL; $homepageUri = !empty($list_addon->homepageUri) ? safe_url($list_addon->homepageUri) : NULL; // Construct and configure a new Addon instance. $addon = new Addon($title, $version, $downloadUri, $homepageUri); foreach ($list_addon->attributes() as $key => $value) { $attrib = clean_text($key); $value = clean_text($value); $addon->setAttrib($attrib, (int) eval('return (' . $value . ');')); } if (!empty($list_addon->description)) { $addon->setDescription(clean_text($list_addon->description)); } if (!empty($list_addon->notes)) { $addon->setNotes(clean_text($list_addon->notes)); } return $addon; }