public static function PHPUnit_Util_Class::getPackageInformation

Returns the package information of a user-defined class.

Parameters

string $className:

string $docComment:

Return value

array

1 call to PHPUnit_Util_Class::getPackageInformation()
PHPUnit_Util_Log_JUnit::startTestSuite in drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/Log/JUnit.php
A testsuite started.

File

drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/Class.php, line 202

Class

PHPUnit_Util_Class
Class helpers.

Code

public static function getPackageInformation($className, $docComment) {
  $result = array(
    'namespace' => '',
    'fullPackage' => '',
    'category' => '',
    'package' => '',
    'subpackage' => '',
  );
  if (strpos($className, '\\') !== FALSE) {
    $result['namespace'] = self::arrayToName(explode('\\', $className));
  }
  if (preg_match('/@category[\\s]+([\\.\\w]+)/', $docComment, $matches)) {
    $result['category'] = $matches[1];
  }
  if (preg_match('/@package[\\s]+([\\.\\w]+)/', $docComment, $matches)) {
    $result['package'] = $matches[1];
    $result['fullPackage'] = $matches[1];
  }
  if (preg_match('/@subpackage[\\s]+([\\.\\w]+)/', $docComment, $matches)) {
    $result['subpackage'] = $matches[1];
    $result['fullPackage'] .= '.' . $matches[1];
  }
  if (empty($result['fullPackage'])) {
    $result['fullPackage'] = self::arrayToName(explode('_', str_replace('\\', '_', $className)), '.');
  }
  return $result;
}