# CRUDlex\YamlReader

class `YamlReader`

  Reads Yaml files and caches them if a writable path is given. The cache is used first on the next read. It is a simple PHP class internally.

  property `cachePath`

    protected string

    The path for the cache files.

  `getCacheFile`($fileName)

    Gets an absolute path for a cache file.

    Parameters: | $fileName (string) – the file to cache
    Returns: | string the absolute path of the cache file

  `readFromCache`($fileName)

    Reads the content of the cached file if it exists.

    Parameters: | $fileName (string) – the cache file to read from
    Returns: | null|array the cached data structure or null if the cache file was not available

  `writeToCache`($fileName, $content)

    Writes the given content to a cached PHP file.

    Parameters: | $fileName (string) – the original filename $content (array) – the content to cache

  `__construct`($cachePath)

    YamlReader constructor.

    Parameters: | $cachePath (string|null) – if given, the path for the cache files which should be a writable directory

  `read`($fileName)

    Reads and returns the contents of the given Yaml file. If it goes wrong, it throws an exception.

    Parameters: | $fileName (string) – the file to read
    Returns: | array the file contents