/** * Loads given XML $inputFile * * @param string $inputFile * * @throws \InvalidArgumentException */ public function __construct($inputFile) { $inputFile = FileUtils::cleanFilename($inputFile); if (!file_exists($inputFile)) { throw new \InvalidArgumentException('cannot locate [$inputFile] file!'); } $this->inputFile = Utils::getXMLFile($inputFile); }
/** * Returns a XML Resource filename for the uncompressed contents of the provided zipped $filename * * @param string $filename of zipped XML data * * @throws Exception ZipArchive extension is not loaded or the ZIP file is corrupt * * @return string Full filename and path of extracted XML file */ private static function getZippedFile($filename) { if (!self::zipModuleLoaded()) { throw new Exception('The ZipArchive extension is not loaded. Load the extension or use the flat wurfl.xml file'); } $tmpDir = FileUtils::getTempDir(); $zip = new \ZipArchive(); if ($zip->open($filename) !== true) { throw new Exception('The Zip file <$filename> could not be opened'); } $zippedFile = $zip->statIndex(0); $wurflFile = $zippedFile['name']; $zip->extractTo($tmpDir); $zip->close(); return FileUtils::cleanFilename($tmpDir . DIRECTORY_SEPARATOR . $wurflFile); }