PHP_CodeSniffer
[ class tree: PHP_CodeSniffer ] [ index: PHP_CodeSniffer ] [ all elements ]

Source for file Svnblame.php

Documentation is available at Svnblame.php

  1. <?php
  2. /**
  3.  * SVN blame report for PHP_CodeSniffer.
  4.  *
  5.  * @author    Greg Sherwood <gsherwood@squiz.net>
  6.  * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
  7.  * @license   https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
  8.  */
  9.  
  10. namespace PHP_CodeSniffer\Reports;
  11.  
  12. class Svnblame extends VersionControl
  13. {
  14.  
  15.     /**
  16.      * The name of the report we want in the output
  17.      *
  18.      * @var string 
  19.      */
  20.     protected $reportName 'SVN';
  21.  
  22.  
  23.     /**
  24.      * Extract the author from a blame line.
  25.      *
  26.      * @param string $line Line to parse.
  27.      *
  28.      * @return mixed string or false if impossible to recover.
  29.      */
  30.     protected function getAuthor($line)
  31.     {
  32.         $blameParts = array();
  33.         preg_match('|\s*([^\s]+)\s+([^\s]+)|'$line$blameParts);
  34.  
  35.         if (isset($blameParts[2]=== false{
  36.             return false;
  37.         }
  38.  
  39.         return $blameParts[2];
  40.  
  41.     }//end getAuthor()
  42.  
  43.  
  44.     /**
  45.      * Gets the blame output.
  46.      *
  47.      * @param string $filename File to blame.
  48.      *
  49.      * @return array 
  50.      */
  51.     protected function getBlameContent($filename)
  52.     {
  53.         $command 'svn blame "'.$filename.'" 2>&1';
  54.         $handle  popen($command'r');
  55.         if ($handle === false{
  56.             echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL;
  57.             exit(3);
  58.         }
  59.  
  60.         $rawContent stream_get_contents($handle);
  61.         fclose($handle);
  62.  
  63.         $blames explode("\n"$rawContent);
  64.  
  65.         return $blames;
  66.  
  67.     }//end getBlameContent()
  68.  
  69.  
  70. }//end class

Documentation generated on Mon, 11 Mar 2019 14:18:14 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.