Read the contents of a csv file, and throw a RuntimeException if it cannot be done.

@param string $filename The path to the file

@return array The data read from the file
775194
public static function getContents($filename)
    {
        $file = fopen($filename, "r");

        if ($file === false) {
            throw new \RuntimeException("Cannot read the file: {$filename}");
        }

        $data = [];
        while ($row = fgetcsv($file)) {
            $data[] = $row;
        }

        fclose($file);

        return $data;
    }
174807
public static function read($fileName)
    {
        $data = parent::read($fileName);

        $json = json_decode($data, true);

        if (json_last_error()) {
            throw new \RuntimeException(json_last_error_msg());
        }

        return $json;
    }
267437
public static function parseFile($filename)
    {
        $file = new SplFileInfo($filename);

        if (!$file->isFile()) {
            throw new RuntimeException('Invalid filename supplied for `RadHam\Yaml::parseFile()`.');
        }

        $contents = file_get_contents($file->getPathname());

        return self::parse($contents);
    }
71185
public function readString()
	{
		if( !$this->exists( $this->fileName ) )
			throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' );
		if( !$this->isReadable( $this->fileName ) )
			throw new RuntimeException( 'File "'.$this->fileName.'" is not readable' );
		return file_get_contents( $this->fileName );
	}
393885
public function getContents(string $fileName)
    {
        if (!file_exists($this->__path . $fileName)) {
            return null;
        }
        $r = include $this->__path . $fileName;
        return $r === false ? null : $r;
    }
1261413
protected function getData( $filename )
    {

        $matches = [];

        $regex = '/(.+)-([0-9_]+)x([0-9_]+)(-resize)*(\-\[([\-\d\.]+)x([\-\d\.]+)\])*\.([A-z]+)$/';

        preg_match( $regex, $filename, $matches );


        $path = $matches[1];
        $extension = $matches[8];
        $imagePath = sprintf( '%s/%s.%s', dirname( $filename ), basename( $path ), $extension );

        $width = $matches[2];
        $height = $matches[3];

        $focusX = $matches[6];
        $focusY = $matches[7];

        return [
            'filepath'=> $imagePath,
            'resize'=> $matches[4] != '',

            'width'=> $width != '_' ? $width : null,
            'height'=> $height != '_' ? $height : null,

            'focusX' => $focusX != '' ? $focusX : null,
            'focusY' => $focusY != '' ? $focusY : null,
        ];

    }
318991
public function load(string $filename): \Nofuzz\Config\Config
  {
    # Attempt to load config file
    if ( file_exists($filename) ) {
      # Set filename
      $this->filename = $filename;
      # Load the config
      $configArray = json_decode( file_get_contents($filename), true);
      if ($configArray) {
        // $configArray = $this->array_change_key_case_recursive($configArray); // Lowercase the keys
        # Merge the Config with existing config
        // $this->confValues = array_replace_recursive($this->confValues, $configArray);
        $this->confValues = $configArray;
      } else {
        throw new \RunTimeException('Invalid JSON file "'.$filename.'"');

      }
    } else {
      throw new \RunTimeException('Config file "'.$filename.'" not found');

    }

    return $this;
  }
1116576
public function readFrom($input)
    {
        if ($this->isFile($input)) {
            if (is_readable($input) === false) {
                throw new \RuntimeException(
                    sprintf('Unable to parse "%s" as the file is not readable.', $input)
                );
            }

            // $input is a filepath, so we load that file
            $input = file_get_contents($input);
        }

        return trim($input);
    }
129911
public function getFileContents($filename)
    {
        if ($contents = file_get_contents($filename)) {
            if (preg_match('/<body ?.*?>(.+)<\/body>/s', $contents, $matches)) {
                return $matches[1];
            } else { // it's not HTML, so output it as plain text
                return $contents;
            }
        }
        return FALSE;
    }
1096781
function read($filename){
		$filename = md5($filename);
		$filepath = $this->getConfig('cache_path').$filename.'.tmp';
		
		if(!file_exists($filepath)){
			return FALSE;
		}
		
		if ( ! $fp = @fopen($filepath, 'r')){
			return FALSE;
		}
		flock($fp, LOCK_SH);

		$cache = '';
		if (filesize($filepath) > 0)
		{
			$cache = fread($fp, filesize($filepath));
		}

		flock($fp, LOCK_UN);
		fclose($fp);

		// Strip out the embedded timestamp
		if ( ! preg_match("/(\d+T_SKY-->)/", $cache, $match))
		{
			return FALSE;
		}
		// Has the file expired? If so we'll delete it.
		if (time() >= trim(str_replace('TS--->', '', $match['1'])))
		{
			if (is_writable($filepath))
			{
				@unlink($filepath);
				return FALSE;
			}
		}

		// Display the cache
		return str_replace($match['0'], '', $cache);
	}
795117
public function
	Read(String $Filename=NULL) {

		if($Filename === NULL) $Filename = $this->Filename;
		else $this->Filename = $Filename;

		if(!$Filename)
		throw new Exception('No filename specified.');

		$Basename = basename($Filename);
		$Ext = NULL;

		if(strpos($Basename,'.') !== FALSE)
		$Ext = strtolower(explode('.',$Basename,2)[1]);

		////////
		////////

		if(!file_exists($Filename))
		throw new Exception("File {$Basename} not found.");

		if(!is_readable($Filename))
		throw new Exception("File {$Basename} is not readable.");

		////////
		////////

		if($Ext === 'json' || $this->Format === static::FormatJSON)
		$this->Data = json_decode(file_get_contents($Filename));

		elseif($Ext === 'phson' || $this->Format === static::FormatPHP)
		$this->Data = unserialize(file_get_contents($Filename));

		////////
		////////

		if(is_object($this->Data))
		$this->Data = (array)$this->Data;

		return $this;
	}
1158051
public function get($filename)
    {
        $filename = $this->path($filename);

        if (!(is_file($filename) && stream_is_local($filename))) {
            return null;
        }

        return file_get_contents($filename);
    }
280697
protected function load($filename)
    {
        $this->catalog = array();

        $fp = fopen($filename, 'rb', false);
        if ($fp === false) {
            throw new \RuntimeException("Could not read $filename");
        }

        $data = fread($fp, 20);
        if (strlen($data) != 20) {
            throw new \RuntimeException('Invalid file');
        }

        $magic = substr($data, 0, 4);
        if ($magic === "\x95\x04\x12\xde") {
            $dword = 'N';
        } elseif ($magic === "\xde\x12\x04\x95") {
            $dword = 'V';
        } else {
            throw new \RuntimeException('Invalid file');
        }

        list(, $revision) = unpack("@4/${dword}", $data);

        if ($revision !== 0) {
            throw new \RuntimeException('Invalid file');
        }

        list(, $count, $origOffset, $transOffset) = unpack("@8/${dword}3", $data);

        fseek($fp, $origOffset);
        $origEntries = array();
        for ($i = 0; $i < $count; $i++) {
            $origEntries[] = unpack("${dword}2", fread($fp, 8));
        }

        fseek($fp, $transOffset);
        $transEntries = array();
        for ($i = 0; $i < $count; $i++) {
            $transEntries[] = unpack("${dword}2", fread($fp, 8));
        }

        for ($i = 0; $i < $count; $i++) {
            fseek($fp, $origEntries[$i][2]);
            $msgid = $origEntries[$i][1] > 0 ? fread($fp, $origEntries[$i][1]) : "";
            fseek($fp, $transEntries[$i][2]);
            $translations = $transEntries[$i][1] > 0 ? explode("\x00", fread($fp, $transEntries[$i][1])) : "";

            $ctx = self::NO_CONTEXT;
            if (($pos = strpos($msgid, self::NO_CONTEXT)) !== false) {
                $ctx = (string) substr($msgid, 0, $pos);
                $msgid = (string) substr($msgid, $pos + 1);
            }

            $this->catalog[$ctx][$msgid] = $translations;
        }
    }
1326013
public static function arrayToCsvFile($filename, $data)
    {
        $fp = fopen($filename, 'w');

        foreach ($data as $fields) {
            fputcsv($fp, $fields);
        }

        fclose($fp);
    }
133596
public static function checkFile($filename)
    {
        $fileContents = (is_file($filename) && is_readable($filename)) ? @file_get_contents($filename) : false;
        if ($fileContents === false) {
            throw new Exception('Failed to load the file '.$filename);
        }

        return static::checkString($fileContents, $filename);
    }
502217
public function getSqlFileByName($fileName)
    {
        $sqlFinder = $this->getFinder();

        $files = $sqlFinder->files()
            ->in($this->sqlFilesDir)
            ->name($fileName)
        ;

        if ($files->count() !== 1) {
            throw new RuntimeException('cannot find File:' . $fileName);
        }

        foreach ($files as $file){
            return $file;
        }
    }
232884
public static function loadRuntimeInfo($fileName)
    {
        if(!is_file($fileName))
        {
            return false;
        }
        static::$runtimeInfo = unserialize(file_get_contents($fileName));
        $data = static::$runtimeInfo->annotationParserData;
        Annotation::getInstance()->getParser()->setData($data[0]);
        Annotation::getInstance()->getParser()->setFileMap($data[1]);
        Annotation::getInstance()->getParser()->setParsers(static::$runtimeInfo->annotationParserParsers);
        AnnotationManager::setAnnotations(static::$runtimeInfo->annotationManagerAnnotations);
        AnnotationManager::setAnnotationRelation(static::$runtimeInfo->annotationManagerAnnotationRelation);
        foreach(static::$runtimeInfo->parsersData as $parserClass => $data)
        {
            $parser = $parserClass::getInstance();
            $parser->setData($data);
        }
        return true;
    }