convertToUseRealPath($filePath); return file_get_contents($realFilePath); } /** * Updates the given file path to use a real path. * This is to avoid issues on some Windows setup. * * @param string $filePath File path * @return string The file path using a real path */ protected function convertToUseRealPath($filePath) { $realFilePath = $filePath; if ($this->isZipStream($filePath)) { if (preg_match('/zip:\/\/(.*)#(.*)/', $filePath, $matches)) { $documentPath = $matches[1]; $documentInsideZipPath = $matches[2]; $realFilePath = 'zip://' . realpath($documentPath) . '#' . $documentInsideZipPath; } } else { $realFilePath = realpath($filePath); } return $realFilePath; } /** * Returns whether the given path is a zip stream. * * @param string $path Path pointing to a document * @return bool TRUE if path is a zip stream, FALSE otherwise */ protected function isZipStream($path) { return (strpos($path, 'zip://') === 0); } /** * Wrapper around global function feof() * @see feof() * * @param resource * @return bool */ public function feof($handle) { return feof($handle); } /** * Wrapper around global function is_readable() * @see is_readable() * * @param string $fileName * @return bool */ public function is_readable($fileName) { return is_readable($fileName); } /** * Wrapper around global function basename() * @see basename() * * @param string $path * @param string|void $suffix * @return string */ public function basename($path, $suffix = null) { return basename($path, $suffix); } /** * Wrapper around global function header() * @see header() * * @param string $string * @return void */ public function header($string) { header($string); } /** * Wrapper around global function iconv() * @see iconv() * * @param string $string The string to be converted * @param string $sourceEncoding The encoding of the source string * @param string $targetEncoding The encoding the source string should be converted to * @return string|bool the converted string or FALSE on failure. */ public function iconv($string, $sourceEncoding, $targetEncoding) { return iconv($sourceEncoding, $targetEncoding, $string); } /** * Wrapper around global function mb_convert_encoding() * @see mb_convert_encoding() * * @param string $string The string to be converted * @param string $sourceEncoding The encoding of the source string * @param string $targetEncoding The encoding the source string should be converted to * @return string|bool the converted string or FALSE on failure. */ public function mb_convert_encoding($string, $sourceEncoding, $targetEncoding) { return mb_convert_encoding($string, $targetEncoding, $sourceEncoding); } /** * Wrapper around global function stream_get_line() * @see stream_get_line() * * @param resource $handle * @param int $length * @param string|void $ending * @return string|bool */ public function stream_get_line($handle, $length, $ending = null) { return stream_get_line($handle, $length, $ending); } /** * Wrapper around global function str_getcsv() * @see str_getcsv() * * @param string $input * @param string|void $delimiter * @param string|void $enclosure * @param string|void $escape * @return array */ public function str_getcsv($input, $delimiter = null, $enclosure = null, $escape = null) { return str_getcsv($input, $delimiter, $enclosure, $escape); } /** * Wrapper around global function function_exists() * @see function_exists() * * @param string $functionName * @return bool */ public function function_exists($functionName) { return function_exists($functionName); } }