SebastianBergmann\PHPLOC\Log\CSV\History::printRow PHP Method

printRow() public method

Print a single row to the output file
public printRow ( array $data )
$data array A single row of data
    public function printRow(array $data)
    {
        if (!$this->isInitialized) {
            $this->isInitialized = true;
            fwrite($this->file, $this->getKeysLine($data));
        }
        fwrite($this->file, $this->getValuesLine($data));
    }

Usage Example

Example #1
0
 /**
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|int null or 0 if everything went fine, or an error code
  */
 private function executeHistory(InputInterface $input, OutputInterface $output)
 {
     $git = new Git($input->getOption('git-repository'));
     $currentBranch = $git->getCurrentBranch();
     $revisions = $git->getRevisions();
     $printer = null;
     $progressBar = null;
     if ($input->getOption('log-csv')) {
         $printer = new History($input->getOption('log-csv'));
     }
     if ($input->getOption('progress')) {
         $progressBar = new ProgressBar($output, count($revisions));
         $progressBar->start();
     }
     foreach ($revisions as $revision) {
         $git->checkout($revision['sha1']);
         $directories = [];
         foreach ($input->getArgument('values') as $value) {
             $directory = realpath($value);
             if ($directory) {
                 $directories[] = $directory;
             }
         }
         $_count = $this->count($directories, $input->getOption('exclude'), $this->handleCSVOption($input, 'names'), $this->handleCSVOption($input, 'names-exclude'), $input->getOption('count-tests'));
         if ($_count) {
             $_count['commit'] = $revision['sha1'];
             $_count['date'] = $revision['date']->format(\DateTime::W3C);
             if ($printer) {
                 $printer->printRow($_count);
             }
         }
         if ($progressBar !== null) {
             $progressBar->advance();
         }
     }
     $git->checkout($currentBranch);
     if ($progressBar !== null) {
         $progressBar->finish();
         $output->writeln('');
     }
 }