예제 #1
0
 public function getLine($filename, $line, $context = 2)
 {
     if (!$this->filesystem->exists($filename)) {
         throw new \RuntimeException('File not found: ' . $filename);
     }
     $file = $this->filesystem->getFile($filename);
     return $file->getLine($line, $context);
 }
예제 #2
0
 /**
  * @param FileParser\AbstractParser $parser
  * @param $outputDir
  * @return string file written
  */
 public function generateReport(FileParser\AbstractParser $parser, $outputDir)
 {
     $outputDir = rtrim($outputDir, '/\\');
     if (!$this->filesystem->exists($outputDir)) {
         $this->filesystem->mkdir($outputDir);
     }
     //lock and update metadata
     $metaFile = "{$outputDir}/" . self::META_FILE;
     $this->filesystem->lockedWrite($metaFile, function ($handle) use($parser) {
         $metaData = array('reports' => array());
         if ($existingMeta = json_decode(fgets($handle), true)) {
             $metaData['reports'] = array_merge($metaData['reports'], $existingMeta['reports']);
         }
         $metaData['reports'][$parser->getRealName()] = array('file' => "{$parser->getFilename()}.html", 'description' => $parser->getDescription());
         //flush to disk
         return json_encode($metaData);
     });
     //flush report
     $outfile = "{$outputDir}/{$parser->getFilename()}.html";
     $this->filesystem->dumpFile($outfile, $this->templateEngine->render($parser->getFilename(), array('data' => $parser->getData())));
     return $outfile;
 }