Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Gitblame.php

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

Gitblame

Namespace

PHP_CodeSniffer\Reports

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal