createForUnparsableFile() 공개 정적인 메소드

public static createForUnparsableFile ( string $file, integer $code, Throwable $previous = null ) : UnparsableFileException
$file string
$code integer
$previous Throwable
리턴 UnparsableFileException
예제 #1
0
파일: YamlParser.php 프로젝트: nelmio/alice
 /**
  * {@inheritDoc}
  *
  * @param string $file Local YAML file
  *
  * @throws ParseException
  */
 public function parse(string $file) : array
 {
     if (false === file_exists($file)) {
         throw InvalidArgumentExceptionFactory::createForFileCouldNotBeFound($file);
     }
     try {
         $data = $this->yamlParser->parse(file_get_contents($file));
         // $data is null only if the YAML file was empty; otherwise an exception is thrown
         return null === $data ? [] : $data;
     } catch (\Exception $exception) {
         if ($exception instanceof SymfonyParseException) {
             throw ParseExceptionFactory::createForInvalidYaml($file, 0, $exception);
         }
         throw ParseExceptionFactory::createForUnparsableFile($file, 0, $exception);
     }
 }