You are here

public function VersionParser::normalizeBranch in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/composer/semver/src/VersionParser.php \Composer\Semver\VersionParser::normalizeBranch()

Normalizes a branch name to be able to perform comparisons on it.

Parameters

string $name:

Return value

string

1 call to VersionParser::normalizeBranch()
VersionParser::normalize in vendor/composer/semver/src/VersionParser.php
Normalizes a version string to be able to perform comparisons on it.

File

vendor/composer/semver/src/VersionParser.php, line 187

Class

VersionParser
Version parser.

Namespace

Composer\Semver

Code

public function normalizeBranch($name) {
  $name = trim($name);
  if (in_array($name, array(
    'master',
    'trunk',
    'default',
  ))) {
    return $this
      ->normalize($name);
  }
  if (preg_match('{^v?(\\d+)(\\.(?:\\d+|[xX*]))?(\\.(?:\\d+|[xX*]))?(\\.(?:\\d+|[xX*]))?$}i', $name, $matches)) {
    $version = '';
    for ($i = 1; $i < 5; ++$i) {
      $version .= isset($matches[$i]) ? str_replace(array(
        '*',
        'X',
      ), 'x', $matches[$i]) : '.x';
    }
    return str_replace('x', '9999999', $version) . '-dev';
  }
  return 'dev-' . $name;
}