parseByFilename($fname); $entries = array(); foreach (array_values($parsedData['compatibility']['company']) as $value) { $games = array(); if (is_array($value['games'])) { foreach ($value['games']['game'] as $data) { $games[] = new LegacyCompatGame($data); } $entries[$value['name']] = $games; } } return $entries; } /* Get version numbers for all available compatibility charts, excluding the DEV charts. */ public static function getAllVersions() { if (!($files = scandir(DIR_COMPAT))) { throw new \ErrorException(self::NO_FILES); } $retVal = []; foreach ($files as $file) { if (substr($file, -4) !== '.xml') { continue; } $ver = \substr(str_replace(".xml", "", $file), 7); $retVal[$ver] = true; } return $retVal; } /* Get a specific LegacyCompatGame-object for the requested version. */ public static function getGameData($version, $target) { if (!is_string($version) || !is_string($target)) { throw new \ErrorException(self::NO_VERSION_TARGET); } if (!($all_games = self::getAllData($version))) { throw new \ErrorException(self::NOT_FOUND); } $g = null; foreach ($all_games as $company => $games) { foreach ($games as $game) { if ($game->getTarget() == $target) { $g = $game; break; } } if ($g != null) { break; } } if (is_null($g)) { throw new \ErrorException(self::NOT_FOUND); } return $g; } }