src/CRUDlex/YamlReader.php
public function read($fileName)
    {
        $parsedYaml = $this->readFromCache($fileName);
        if ($parsedYaml !== null) {
            return $parsedYaml;
        }

        try {
            $fileContent = file_get_contents($fileName);
            $parsedYaml  = Yaml::parse($fileContent);
            if (!is_array($parsedYaml)) {
                $parsedYaml = [];
            }
            $this->writeToCache($fileName, $parsedYaml);
            return $parsedYaml;
        } catch (\Exception $e) {
            throw new \RuntimeException('Could not read Yaml file '.$fileName, $e->getCode(), $e);
        }
    }
public function read($fileName)
    {
        $parsedYaml = $this->readFromCache($fileName);
        if ($parsedYaml !== null) {
            return $parsedYaml;
        }

        try {
            $fileContent = file_get_contents($fileName);
            $parsedYaml  = Yaml::parse($fileContent);
            if (!is_array($parsedYaml)) {
                $parsedYaml = [];
            }
            $this->writeToCache($fileName, $parsedYaml);
            return $parsedYaml;
        } catch (\Exception $e) {
            throw new \RuntimeException('Could not read Yaml file '.$fileName, $e->getCode(), $e);
        }
    }
public function read ( $ fileName ) { $ parsedYaml = $ this -> readFromCache ( $ fileName ) ; if ( $ parsedYaml !== null ) { return $ parsedYaml ; } try { $ fileContent = file_get_contents ( $ fileName ) ; $ parsedYaml = Yaml :: parse ( $ fileContent ) ; if ( ! is_array ( $ parsedYaml ) ) { $ parsedYaml = [ ] ; } $ this -> writeToCache ( $ fileName , $ parsedYaml ) ; return $ parsedYaml ; } catch ( \ Exception $ e ) { throw new \ RuntimeException ( 'Could not read Yaml file ' . $ fileName , $ e -> getCode ( ) , $ e ) ; } }
Reads and returns the contents of the given Yaml file. If
it goes wrong, it throws an exception.

@param string $fileName
the file to read

@return array
the file contents

@throws \RuntimeException
thrown if the file could not be read or parsed
Reads and returns the contents of the given Yaml file . If it goes wrong it throws an exception .