class SemanticVersion

Same name in other branches
  1. 9 composer/Util/SemanticVersion.php \Drupal\Composer\Util\SemanticVersion
  2. 11.x composer/Util/SemanticVersion.php \Drupal\Composer\Util\SemanticVersion

Utility methods for manipulating semantic versions.

Hierarchy

Expanded class hierarchy of SemanticVersion

1 file declares its use of SemanticVersion
ComponentGenerator.php in composer/Generator/ComponentGenerator.php

File

composer/Util/SemanticVersion.php, line 8

Namespace

Drupal\Composer\Util
View source
class SemanticVersion {
    
    /**
     * Given a version, generate a loose ^major.minor constraint.
     *
     * @param string $version
     *   Semantic version string. Example: 9.5.0-beta23.
     *
     * @return string
     *   Constraint string for major and minor. Example: ^9.5
     */
    public static function majorMinorConstraint(string $version) : string {
        preg_match('/^(\\d+)\\.(\\d+)\\.\\d+/', $version, $matches);
        return '^' . $matches[1] . '.' . $matches[2];
    }

}

Members

Title Sort descending Modifiers Object type Summary
SemanticVersion::majorMinorConstraint public static function Given a version, generate a loose ^major.minor constraint.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.