You are here

public static function ModuleVersion::createFromSupportBranch in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/update/src/ModuleVersion.php \Drupal\update\ModuleVersion::createFromSupportBranch()

Constructs a module version object from a support branch.

This can be used to determine the major version of the branch. ::getVersionExtra() will always return NULL for branches.

Parameters

string $branch: The support branch.

Return value

\Drupal\update\ModuleVersion The module version instance.

Throws

\UnexpectedValueException Thrown when $branch is not valid because it does not end in ".".

3 calls to ModuleVersion::createFromSupportBranch()
ModuleVersionTest::testCreateFromSupportBranch in core/modules/update/tests/src/Unit/ModuleVersionTest.php
@covers ::createFromSupportBranch
ModuleVersionTest::testInvalidBranch in core/modules/update/tests/src/Unit/ModuleVersionTest.php
@covers ::createFromSupportBranch
ModuleVersionTest::testInvalidBranchCorePrefix in core/modules/update/tests/src/Unit/ModuleVersionTest.php
@covers ::createFromSupportBranch

File

core/modules/update/src/ModuleVersion.php, line 116

Class

ModuleVersion
Provides a module version value object.

Namespace

Drupal\update

Code

public static function createFromSupportBranch($branch) {
  if (substr($branch, -1) !== '.') {
    throw new \UnexpectedValueException("Invalid support branch: {$branch}");
  }
  return static::createFromVersionString($branch . '0');
}