You are here

public static function TestDiscovery::parseTestClassSummary in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/TestDiscovery.php \Drupal\simpletest\TestDiscovery::parseTestClassSummary()

Parses the phpDoc summary line of a test class.

Parameters

string $doc_comment.:

Return value

string The parsed phpDoc summary line. An empty string is returned if no summary line can be parsed.

1 call to TestDiscovery::parseTestClassSummary()
TestDiscovery::getTestInfo in core/modules/simpletest/src/TestDiscovery.php
Retrieves information about a test class for UI purposes.

File

core/modules/simpletest/src/TestDiscovery.php, line 361
Contains \Drupal\simpletest\TestDiscovery.

Class

TestDiscovery
Discovers available tests.

Namespace

Drupal\simpletest

Code

public static function parseTestClassSummary($doc_comment) {

  // Normalize line endings.
  $doc_comment = preg_replace('/\\r\\n|\\r/', '\\n', $doc_comment);

  // Strip leading and trailing doc block lines.
  $doc_comment = substr($doc_comment, 4, -4);
  $lines = explode("\n", $doc_comment);
  $summary = [];

  // Add every line to the summary until the first empty line or annotation
  // is found.
  foreach ($lines as $line) {
    if (preg_match('/^[ ]*\\*$/', $line) || preg_match('/^[ ]*\\* \\@/', $line)) {
      break;
    }
    $summary[] = trim($line, ' *');
  }
  return implode(' ', $summary);
}