Google\Cloud\Dev\DocGenerator\Writer::write PHP Method

write() public method

public write ( $currentFile )
    public function write($currentFile)
    {
        $path = $this->buildOutputPath($currentFile);
        if (!is_dir(dirname($path))) {
            mkdir(dirname($path), 0777, true);
        }
        file_put_contents($path, $this->content);
    }

Usage Example

 /**
  * Generates JSON documentation from provided files.
  *
  * @return void
  */
 public function generate()
 {
     foreach ($this->files as $file) {
         $currentFile = substr(str_replace($this->executionPath, '', $file), 3);
         $isPhp = strrpos($file, '.php') == strlen($file) - strlen('.php');
         if ($isPhp) {
             $fileReflector = new FileReflector($file);
             $parser = new CodeParser($file, $currentFile, $fileReflector);
         } else {
             $content = file_get_contents($file);
             $parser = new MarkdownParser($currentFile, $content);
         }
         $document = $parser->parse();
         $writer = new Writer(json_encode($document), $this->outputPath);
         $writer->write(substr($currentFile, 4));
         $this->types->addType(['id' => $document['id'], 'title' => $document['title'], 'contents' => $document['id'] . '.json']);
     }
 }
All Usage Examples Of Google\Cloud\Dev\DocGenerator\Writer::write