/**
  * Create file format object
  *
  * @param  InputInterface $input
  * @param  SplFileObject  $file
  * @return Format\FormatInterface
  */
 private function createFormat(InputInterface $input, SplFileObject $file)
 {
     $formatIdentifier = $input->getOption('format');
     if (!$formatIdentifier) {
         $formatIdentifier = $file->getExtension();
     }
     $formatFactory = new readmetester\Format\FormatFactory();
     return $formatFactory->createFormat($formatIdentifier);
 }
 /**
  * Validate code examples in $file
  *
  * @param  \SplFileObject $file
  * @param  string         $formatIdentifier
  * @return void
  */
 public function assertFile(\SplFileObject $file, $formatIdentifier = '')
 {
     $format = $this->formatFactory->createFormat($formatIdentifier ?: $file->getExtension());
     $result = $this->testCase->getTestResultObject();
     foreach ($this->tester->test($file, $format) as $example => $returnObj) {
         $this->testCase->addToAssertionCount(1);
         if ($returnObj->isFailure()) {
             $result->addFailure($this->testCase, new \PHPUnit_Framework_AssertionFailedError("Example {$example}: {$returnObj->getMessage()}"), 0.0);
         }
     }
 }