You are here

public function Parser::parseFile in Lockr 7.3

Parses a YAML file into a PHP value.

Parameters

string $filename The path to the YAML file to be parsed:

int $flags A bit field of PARSE_* constants to customize the YAML parser behavior:

Return value

mixed The YAML converted to a PHP value

Throws

ParseException If the file could not be read or the YAML is not valid

File

vendor/symfony/yaml/Parser.php, line 65

Class

Parser
Parser parses YAML strings to convert them to PHP arrays.

Namespace

Symfony\Component\Yaml

Code

public function parseFile($filename, $flags = 0) {
  if (!is_file($filename)) {
    throw new ParseException(sprintf('File "%s" does not exist.', $filename));
  }
  if (!is_readable($filename)) {
    throw new ParseException(sprintf('File "%s" cannot be read.', $filename));
  }
  $this->filename = $filename;
  try {
    return $this
      ->parse(file_get_contents($filename), $flags);
  } finally {
    $this->filename = null;
  }
}