You are here

protected function LintCommand::execute in Lockr 7.3

File

vendor/symfony/yaml/Command/LintCommand.php, line 81

Class

LintCommand
Validates YAML files syntax and outputs encountered errors.

Namespace

Symfony\Component\Yaml\Command

Code

protected function execute(InputInterface $input, OutputInterface $output) {
  $io = new SymfonyStyle($input, $output);
  $filename = $input
    ->getArgument('filename');
  $this->format = $input
    ->getOption('format');
  $this->displayCorrectFiles = $output
    ->isVerbose();
  $flags = $input
    ->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0;
  if (!$filename) {
    if (!($stdin = $this
      ->getStdin())) {
      throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
    }
    return $this
      ->display($io, [
      $this
        ->validate($stdin, $flags),
    ]);
  }
  if (!$this
    ->isReadable($filename)) {
    throw new RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
  }
  $filesInfo = [];
  foreach ($this
    ->getFiles($filename) as $file) {
    $filesInfo[] = $this
      ->validate(file_get_contents($file), $flags, $file);
  }
  return $this
    ->display($io, $filesInfo);
}