function ModuleVersion::createFromSupportBranch

Same name and namespace in other branches
  1. 9 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.

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 104

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');
}

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