function SemanticVersion::majorMinorConstraint
Given a version, generate a loose ^major.minor constraint.
Parameters
string $version: Semantic version string. Example: 9.5.0-beta23.
Return value
string Constraint string for major and minor. Example: ^9.5
1 call to SemanticVersion::majorMinorConstraint()
- ComponentGenerator::getPackage in composer/
Generator/ ComponentGenerator.php - Reconcile component dependencies with core.
File
-
composer/
Util/ SemanticVersion.php, line 19
Class
- SemanticVersion
- Utility methods for manipulating semantic versions.
Namespace
Drupal\Composer\UtilCode
public static function majorMinorConstraint(string $version) : string {
preg_match('/^(\\d+)\\.(\\d+)\\.\\d+/', $version, $matches);
return '^' . $matches[1] . '.' . $matches[2];
}