function Gitblame::getAuthor
Extract the author from a blame line.
Parameters
string $line Line to parse.:
Return value
mixed string or false if impossible to recover.
Overrides VersionControl::getAuthor
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Reports/ Gitblame.php, line 33
Class
Namespace
PHP_CodeSniffer\ReportsCode
protected function getAuthor($line) {
$blameParts = [];
$line = preg_replace('|\\s+|', ' ', $line);
preg_match('|\\(.+[0-9]{4}-[0-9]{2}-[0-9]{2}\\s+[0-9]+\\)|', $line, $blameParts);
if (isset($blameParts[0]) === false) {
return false;
}
$parts = explode(' ', $blameParts[0]);
if (count($parts) < 2) {
return false;
}
$parts = array_slice($parts, 0, count($parts) - 2);
$author = preg_replace('|\\(|', '', implode(' ', $parts));
return $author;
}