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. use PHP_CodeSniffer\Exceptions\DeepExitException;
  13.  
  14. class Svnblame extends VersionControl
  15. {
  16.  
  17.     /**
  18.      * The name of the report we want in the output
  19.      *
  20.      * @var string 
  21.      */
  22.     protected $reportName 'SVN';
  23.  
  24.  
  25.     /**
  26.      * Extract the author from a blame line.
  27.      *
  28.      * @param string $line Line to parse.
  29.      *
  30.      * @return mixed string or false if impossible to recover.
  31.      */
  32.     protected function getAuthor($line)
  33.     {
  34.         $blameParts = array();
  35.         preg_match('|\s*([^\s]+)\s+([^\s]+)|'$line$blameParts);
  36.  
  37.         if (isset($blameParts[2]=== false{
  38.             return false;
  39.         }
  40.  
  41.         return $blameParts[2];
  42.  
  43.     }//end getAuthor()
  44.  
  45.  
  46.     /**
  47.      * Gets the blame output.
  48.      *
  49.      * @param string $filename File to blame.
  50.      *
  51.      * @return array 
  52.      */
  53.     protected function getBlameContent($filename)
  54.     {
  55.         $command 'svn blame "'.$filename.'" 2>&1';
  56.         $handle  popen($command'r');
  57.         if ($handle === false{
  58.             $error 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL;
  59.             throw new DeepExitException($error3);
  60.         }
  61.  
  62.         $rawContent stream_get_contents($handle);
  63.         fclose($handle);
  64.  
  65.         $blames explode("\n"$rawContent);
  66.  
  67.         return $blames;
  68.  
  69.     }//end getBlameContent()
  70.  
  71.  
  72. }//end class

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